예제 #1
0
        public void addNamespace(XmlNamespaceStartTag tag)
        {
            XmlNamespace nspace = new XmlNamespace(tag.getPrefix(), tag.getUri());

            nspaces.Add(nspace);
            newNamespaces.Add(nspace);
        }
예제 #2
0
 public void onNamespaceStart(XmlNamespaceStartTag tag)
 {
     foreach (XmlStreamer xmlStreamer in xmlStreamers)
     {
         xmlStreamer.onNamespaceStart(tag);
     }
 }
예제 #3
0
        private XmlNamespaceStartTag readXmlNamespaceStartTag()
        {
            int prefixRef = buffer.getInt();
            int uriRef    = buffer.getInt();
            XmlNamespaceStartTag nameSpace = new XmlNamespaceStartTag();

            if (prefixRef > 0)
            {
                nameSpace.setPrefix(stringPool.get(prefixRef));
            }
            if (uriRef > 0)
            {
                nameSpace.setUri(stringPool.get(uriRef));
            }
            return(nameSpace);
        }
예제 #4
0
 public void onNamespaceStart(XmlNamespaceStartTag tag)
 {
     this.namespaces.addNamespace(tag);
 }
예제 #5
0
        /**
         * Parse binary xml.
         */
        public async Task parse()
        {
            ChunkHeader chunkHeader = await readChunkHeader();

            if (chunkHeader == null)
            {
                return;
            }
            if (chunkHeader.getChunkType() != ChunkType.XML && chunkHeader.getChunkType() != ChunkType.NULL)
            {
                // notice that some apk mark xml header type as 0, really weird
                // see https://github.com/clearthesky/apk-parser/issues/49#issuecomment-256852727
                return;
            }

            // read string pool chunk
            chunkHeader = await readChunkHeader();

            if (chunkHeader == null)
            {
                return;
            }
            ParseUtils.checkChunkType(ChunkType.STRING_POOL, chunkHeader.getChunkType());
            stringPool = await ParseUtils.readStringPool(buffer, (StringPoolHeader)chunkHeader);

            // read on chunk, check if it was an optional XMLResourceMap chunk
            chunkHeader = await readChunkHeader();

            if (chunkHeader == null)
            {
                return;
            }
            if (chunkHeader.getChunkType() == ChunkType.XML_RESOURCE_MAP)
            {
                long[] resourceIds = readXmlResourceMap((XmlResourceMapHeader)chunkHeader);
                resourceMap = new string[resourceIds.Length];
                for (int i = 0; i < resourceIds.Length; i++)
                {
                    resourceMap[i] = await Attribute_.AttrIds.getString(resourceIds[i]);
                }
                chunkHeader = await readChunkHeader();
            }

            while (chunkHeader != null)
            {
                /*if (chunkHeader.chunkType == ChunkType.XML_END_NAMESPACE) {
                 *  break;
                 * }*/
                long beginPos = buffer.position();
                switch (chunkHeader.getChunkType())
                {
                case ChunkType.XML_END_NAMESPACE:
                    XmlNamespaceEndTag xmlNamespaceEndTag = readXmlNamespaceEndTag();
                    xmlStreamer.onNamespaceEnd(xmlNamespaceEndTag);
                    break;

                case ChunkType.XML_START_NAMESPACE:
                    XmlNamespaceStartTag namespaceStartTag = readXmlNamespaceStartTag();
                    xmlStreamer.onNamespaceStart(namespaceStartTag);
                    break;

                case ChunkType.XML_START_ELEMENT:
                    XmlNodeStartTag xmlNodeStartTag = await readXmlNodeStartTag();

                    break;

                case ChunkType.XML_END_ELEMENT:
                    XmlNodeEndTag xmlNodeEndTag = readXmlNodeEndTag();
                    break;

                case ChunkType.XML_CDATA:
                    XmlCData xmlCData = await readXmlCData();

                    break;

                default:
                    if (chunkHeader.getChunkType() >= ChunkType.XML_FIRST_CHUNK &&
                        chunkHeader.getChunkType() <= ChunkType.XML_LAST_CHUNK)
                    {
                        Buffers.skip(buffer, chunkHeader.getBodySize());
                    }
                    else
                    {
                        throw new ParserException("Unexpected chunk type:" + chunkHeader.getChunkType());
                    }
                    break;
                }
                buffer.position((int)(beginPos + chunkHeader.getBodySize()));
                chunkHeader = await readChunkHeader();
            }
        }
예제 #6
0
 public void onNamespaceStart(XmlNamespaceStartTag tag)
 {
 }