• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ximpleware.VTDGen类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中com.ximpleware.VTDGen的典型用法代码示例。如果您正苦于以下问题:C# VTDGen类的具体用法?C# VTDGen怎么用?C# VTDGen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VTDGen类属于com.ximpleware命名空间,在下文中一共展示了VTDGen类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Main

 static void Main(string[] args)
 {
     VTDGen vg = new VTDGen();
     AutoPilot ap = new AutoPilot();
     Encoding eg = System.Text.Encoding.GetEncoding("utf-8");
     //ap.selectXPath("/*/*/*");
     AutoPilot ap2 = new AutoPilot();
     ap2.selectXPath("//@*");
     if (vg.parseFile("soap2.xml", true))
     {
         FileStream fs = new FileStream("output.xml", System.IO.FileMode.OpenOrCreate);
         VTDNav vn = vg.getNav();
         ap.bind(vn);
         ap2.bind(vn);
         //ap.evalXPath();
         int i;
         while ((i = ap2.evalXPath()) != -1)
         {
             //System.out.println("attr name ---> "+ i+ " "+vn.toString(i)+"  value ---> "+vn.toString(i+1));
             vn.overWrite(i + 1, eg.GetBytes(""));
         }
         byte[] ba = vn.getXML().getBytes();
         fs.Write(ba,0,ba.Length);
         fs.Close();
     }
 }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:26,代码来源:erase.cs


示例2: Main

        static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            int i;
            if (vg.parseFile("po.xml", true))
            {
                // instantiate a node recorder here
                NodeRecorder nr = new NodeRecorder();
                AutoPilot ap = new AutoPilot();
                VTDNav vn = vg.getNav();
                ap.bind(vn);
                // bind node recorder to vn
                nr.bind(vn);
                ap.selectXPath("(/*/*/*)[position()=1 or position()=10]");
                while ((i = ap.evalXPath()) != -1)
                {
                    nr.record(); // save the selected nodes into nr
                }
                ap.resetXPath(); // a good practice
                nr.resetPointer(); // get into nr's read mode
                // iterating over the nodes recorded by nr
                while ((i = nr.iterate()) != -1)
                {
                    Console.WriteLine("string ==>" + vn.toString(i));
                }

                nr.clear(); //remove all the nodes in nr, buffer is however reused
            }
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:29,代码来源:testNodeRecorder.cs


示例3: Main

 public static void Main(String[] args)
 {
     // instantiate VTDGen and XMLModifier
     VTDGen vg = new VTDGen();
     XMLModifier xm = new XMLModifier();
     AutoPilot ap = new AutoPilot();
     AutoPilot ap2 = new AutoPilot();
     ap.selectXPath("(/*/*/*)[position()>1 and position()<4]");
     ap2.selectXPath("/*/*/*");
     if (vg.parseFile("soap2.xml", true))
     {
         VTDNav vn = vg.getNav();
         xm.bind(vn);
         ap2.bind(vn);
         ap.bind(vn);
         ap2.evalXPath();
         ElementFragmentNs ef = vn.getElementFragmentNs();
         int i = -1;
         while ((i = ap.evalXPath()) != -1)
         {
             xm.insertAfterElement(ef);
         }
         xm.output("new_soap.xml");
     }
 }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:25,代码来源:FragmentTest.cs


示例4: Main

 static void Main(string[] args)
 {
     try
     {
         // open a file and read the content into a byte array
         VTDGen vg = new VTDGen();
         if (vg.parseFile("./servers.xml", true))
         {
             VTDNav vn = vg.getNav();
             AutoPilot ap = new AutoPilot(vn);
             ap.selectElementNS("http://purl.org/dc/elements/1.1/", "*"); // select name space here; * matches any local name
             int count = 0;
             while (ap.iterate())
             {
                 Console.Write("" + vn.getCurrentIndex() + "  ");
                 Console.WriteLine("Element name ==> " + vn.toString(vn.getCurrentIndex()));
                 int t = vn.getText(); // get the index of the text (char data or CDATA)
                 if (t != -1)
                     Console.WriteLine(" Text  ==> " + vn.toNormalizedString(t));
                 Console.WriteLine("\n ============================== ");
                 count++;
             }
             Console.WriteLine("Total # of element " + count);
         }
     }
     catch (NavException e)
     {
         Console.WriteLine(" Exception during navigation " + e);
     }
 }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:30,代码来源:RSSReader2.cs


示例5: Main

        static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            int i;
            AutoPilot ap = new AutoPilot();
            ap.selectXPath("/CATALOG/CD[PRICE < 10]");
            BookMark bm = new BookMark();
            if (vg.parseFile("cd.xml", false))
            {
                VTDNav vn = vg.getNav();
                bm.bind(vn);
                ap.bind(vn);

                //XPath eval returns one node at a time
                while ((i = ap.evalXPath()) != -1)
                {
                    // push the current cursor position
                    //vn.push();
                    bm.recordCursorPosition(); // equivalent to vn.push();
                    // get to the first child
                    if (vn.toElement(VTDNav.FIRST_CHILD, "TITLE"))
                    {
                        int j = vn.getText();
                        if (j != -1)
                            Console.WriteLine(" text node ==>" + vn.toString(j));
                    }
                    // restore the cursor position
                    //vn.pop(); 
                    bm.setCursorPosition(); // equivalent to vn.pop();
                }
                ap.resetXPath();
            }
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:33,代码来源:useBookMark.cs


示例6: Main

 public static void Main(String[] args)
 {
     VTDGen vg = new VTDGen();
     AutoPilot ap0 = new AutoPilot();
     AutoPilot ap1 = new AutoPilot();
     AutoPilot ap2 = new AutoPilot();
     ap0.selectXPath("/root/a");
     ap1.selectXPath("/root/b");
     ap2.selectXPath("/root/c");
     Encoding eg = System.Text.Encoding.GetEncoding("utf-8");
     if (vg.parseFile("old.xml", false))
     {
         VTDNav vn = vg.getNav();
         ap0.bind(vn);
         ap1.bind(vn);
         ap2.bind(vn);
         FileStream fos = new FileStream("new.xml", System.IO.FileMode.OpenOrCreate);
         //fos.Write("<root>".getBytes());
         byte[] ba0,ba1, ba2, ba3, ba4;
         //ba0 = eg.GetBytes("
         ba1 = eg.GetBytes("<root>");
         ba2 = eg.GetBytes("</root>");
         ba3 = eg.GetBytes("\n");
         fos.Write(ba1, 0, ba1.Length);
         byte[] ba = vn.getXML().getBytes();
         while (ap0.evalXPath() != -1)
         {
             long l = vn.getElementFragment();
             int offset = (int)l;
             int len = (int)(l >> 32);
             fos.Write(ba3,0,ba3.Length);
             fos.Write(ba, offset, len);
         }
         ap0.resetXPath();
         while (ap1.evalXPath() != -1)
         {
             long l = vn.getElementFragment();
             int offset = (int)l;
             int len = (int)(l >> 32);
             fos.Write(ba3,0,ba3.Length);
             fos.Write(ba, offset, len);
         }
         ap1.resetXPath();
         while (ap2.evalXPath() != -1)
         {
             long l = vn.getElementFragment();
             int offset = (int)l;
             int len = (int)(l >> 32);
             fos.Write(ba3,0,ba3.Length);
             fos.Write(ba, offset, len);
         }
         ap2.resetXPath();
         fos.Write(ba3,0,ba3.Length);
         fos.Write(ba2,0,ba2.Length);
     }
 }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:56,代码来源:shuffle.cs


示例7: Main

        static void Main(string[] args)
        {
            try
            {
                // open file to output extracted fragments
                System.IO.FileInfo f1 = new System.IO.FileInfo("./out.txt");
                System.IO.FileStream fos = new System.IO.FileStream(f1.FullName, System.IO.FileMode.Create);

                // instantiate the parser
                VTDGen vg = new VTDGen();
                if (vg.parseFile("./soap2.xml", true))
                {
                    VTDNav vn = vg.getNav();
                    // get to the SOAP header
                    if (vn.toElementNS(VTDNav.FC, "http://www.w3.org/2003/05/soap-envelope", "Header"))
                    {
                        if (vn.toElement(VTDNav.FC))
                        // to first child
                        {
                            do
                            {
                                // test MUSTHAVE
                                if (vn.hasAttrNS("http://www.w3.org/2003/05/soap-envelope", "mustUnderstand"))
                                {
                                    long l = vn.getElementFragment();
                                    int len = (int)(l >> 32);
                                    int offset = (int)l;
                                    byte[] b = vn.getXML().getBytes();
                                    fos.Write(b, offset, len); //write the fragment out into out.txt
                                    System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("ASCII");
                                    byte[] bytes = encoder.GetBytes("\n=========\n");

                                    fos.Write(bytes, 0, bytes.Length);
                                }
                            }
                            while (vn.toElement(VTDNav.NS)); // navigate next sibling	 
                        }
                        else
                            System.Console.Out.WriteLine("Header has not child elements");
                    }
                    else
                        System.Console.Out.WriteLine(" Dosesn't have a header");
                    
                    fos.Close();
                }
            }
            catch (NavException e)
            {
                System.Console.Out.WriteLine(" Exception during navigation " + e);
            }
            catch (System.IO.IOException e)
            {
                System.Console.Out.WriteLine(" IO exception condition" + e);
            }

        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:56,代码来源:SOAPProcessor.cs


示例8: Main

        static void Main(string[] args)
        {
            try
            {
                //File f = new File("bioinfo.xml");
                // counting child elements of parlist
                int count = 0;
                // counting child elements of parlist named "par"
                int par_count = 0;
                VTDGen vg = new VTDGen();
                if (vg.parseFile("./bioinfo.xml", true))
                {
                    VTDNav vn = vg.getNav();
                    AutoPilot ap = new AutoPilot();
                    ap.bind(vn);
                    ap.selectXPath("/bix/package/command/parlist");
                    while (ap.evalXPath() != -1)
                        count++;

                    ap.selectXPath("/bix/package/command/parlist/par");
                    while (ap.evalXPath() != -1)
                        par_count++;

                    // print out the results
                    Console.WriteLine(" count ====> " + count);
                    Console.WriteLine(" par_count ==> " + par_count);

                    // verify results using iterators
                    int v = 0;
                    vn.toElement(VTDNav.ROOT);
                    ap = new AutoPilot(vn);
                    ap.selectElement("par");
                    while (ap.iterate())
                    {
                        if (vn.getCurrentDepth() == 4)
                        {
                            v++;
                        }
                    }
                    Console.WriteLine(" verify ==> " + v);
                }
            }
            catch (NavException e)
            {
                Console.WriteLine(" Exception during navigation " + e);
            }
            catch (XPathParseException e)
            {

            }
            catch (XPathEvalException e)
            {

            }
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:55,代码来源:stats2.cs


示例9: parseString

        public static VTDNav parseString(String s)
        {
            VTDGen vg = new VTDGen();
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            vg.setDoc(encoding.GetBytes(s));

            vg.parse(true);

            return vg.getNav();
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:11,代码来源:Program.cs


示例10: Main

 static void Main(string[] args)
 {
     try
     {
         VTDGen vg = new VTDGen();
         if (vg.parseFile("po.xml", true))
         {
             vg.writeIndex("po.vxl");
         }
     }
     catch (Exception e)
     {
     }
 }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:14,代码来源:IndexWrite.cs


示例11: Main

	static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            if (vg.parseFile("mix3.xml", true))
            {
                vg.writeSeparateIndex("mix32.vtd");
            }
            VTDNav vn = vg.loadSeparateIndex("mix3.xml", "mix3.vtd");
            AutoPilot ap = new AutoPilot(vn);
            ap.selectXPath("//*");
            int i;
            while((i=ap.evalXPath())!=-1){
                Console.WriteLine("element name: "+vn.toString(i));
            }
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:15,代码来源:Separate_Index.cs


示例12: Main

        static void Main(string[] args)
        {
            	VTDGen vg = new VTDGen();
		        vg.setDoc(getBytes("<root>good</root>"));
		        vg.parse(true);
		        VTDNav vn = vg.getNav();
		        int i=vn.getText();
		        //print "good"
		        Console.WriteLine("text ---> "+vn.toString(i));
		        if (vn.overWrite(i,getBytes("bad"))){
			        //overwrite, if successful, returns true
			        //print "bad" here 
			         Console.WriteLine("text ---> "+vn.toString(i));
		        }
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:15,代码来源:Overwrite.cs


示例13: Main

        static void Main(string[] args)
        {
            try
            {
                // open file to output extracted fragments
                System.IO.FileInfo f1 = new System.IO.FileInfo("./out.txt");
                System.IO.FileStream fos = new System.IO.FileStream(f1.FullName, System.IO.FileMode.Create);

                // instantiate the parser
                VTDGen vg = new VTDGen();
                if (vg.parseFile("./soap2.xml", true))
                {
                    VTDNav vn = vg.getNav();
                    // get to the SOAP header
                    AutoPilot ap = new AutoPilot();
                    ap.bind(vn);
                    ap.declareXPathNameSpace("ns1", "http://www.w3.org/2003/05/soap-envelope");
                    // get to the SOAP header
                    ap.selectXPath("/ns1:Envelope/ns1:Header/*[@ns1:mustUnderstand]");
                    Console.WriteLine("expr string is " + ap.getExprString());
                    while (ap.evalXPath() != -1)
                    {
                        long l = vn.getElementFragment();
                        int len = (int)(l >> 32);
                        int offset = (int)l;
                        byte[] b = vn.getXML().getBytes();
                        fos.Write(b, offset, len); //write the fragment out into out.txt
                        System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("ASCII");
                        byte[] bytes = encoder.GetBytes("\n=========\n");

                        fos.Write(bytes, 0, bytes.Length);
                    }

                    fos.Close();
                }
            }
            catch (NavException e)
            {
                System.Console.Out.WriteLine(" Exception during navigation " + e);
            }
            catch (System.IO.IOException e)
            {
                System.Console.Out.WriteLine(" IO exception condition" + e);
            }

        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:46,代码来源:SOAPProcessor2.cs


示例14: Main

 static void Main(string[] args)
 {
     try
     {
         VTDGen vg = new VTDGen();
         VTDNav vn = vg.loadIndex("po.vxl");
         AutoPilot ap = new AutoPilot(vn);
         ap.selectXPath("//items");
         int i;
         while ((i = ap.evalXPath()) != -1)
         {
         }
         ap.resetXPath();
     }
     catch (Exception e)
     {
     }
 }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:18,代码来源:IndexLoad.cs


示例15: Main

        public static void Main(String[] args)
        {

            String xml = "<aaaa> <bbbbb> <ccccc> </ccccc> <ccccc/> <ccccc></ccccc> </bbbbb> </aaaa>";
            Encoding eg = Encoding.GetEncoding("utf-8");
            VTDGen vg = new VTDGen();
            vg.setDoc(eg.GetBytes(xml));
            vg.parse(false);
            VTDNav vn = vg.getNav();
            AutoPilot ap = new AutoPilot(vn);
            ap.selectXPath("//*");
            XMLModifier xm = new XMLModifier(vn);
            while (ap.evalXPath() != -1)
            {
                xm.updateElementName("d:/lalalala");
            }
            xm.output("lala.xml");
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:18,代码来源:changeElementName.cs


示例16: Main

 	static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            if (vg.parseFile("mix3.xml", true))
            {
                VTDNav vn = vg.getNav();
                // duplicated VTDNav instances share the same XML, LC buffers and VTD buffers.
                VTDNav vn2 = vn.duplicateNav();
                VTDNav vn3 = vn.duplicateNav();
                AutoPilot ap = new AutoPilot(vn);
                ap.selectXPath("//*");
                int i;
                while ((i = ap.evalXPath()) != -1)
                {
                    Console.WriteLine("element name: " + vn.toString(i));
                }
            }
        }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:18,代码来源:duplicateNav.cs


示例17: Main

 static void Main(string[] args)
 {
     try
     {
         // open a file and read the content into a byte array
         VTDGen vg = new VTDGen();
         if (vg.parseFile("./oldpo.xml", true))
         {
             VTDNav vn = vg.getNav();
             System.IO.FileInfo f1 = new System.IO.FileInfo("./newpo.txt");
             System.IO.FileStream fos = new System.IO.FileStream(f1.FullName, System.IO.FileMode.Create);
             
             AutoPilot ap = new AutoPilot(vn);
             XMLModifier xm = new XMLModifier(vn);
             ap.selectXPath("/purchaseOrder/items/item[@partNum='872-AA']");
             int i = -1;
             while ((i = ap.evalXPath()) != -1)
             {
                 xm.remove();
                 xm.insertBeforeElement("<something/>\n");
             }
             ap.selectXPath("/purchaseOrder/items/item/USPrice[.<40]/text()");
             while ((i = ap.evalXPath()) != -1)
             {
                 xm.updateToken(i, "200");
             }
             xm.output(fos);
             fos.Close();
         }
     }
     catch (NavException e)
     {
         Console.WriteLine(" Exception during navigation " + e);
     }
     catch (ModifyException e)
     {
         Console.WriteLine(" Modify exception occurred " + e);
     }
     catch (System.IO.IOException e)
     {
         System.Console.Out.WriteLine(" IO exception condition" + e);
     }
 }
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:43,代码来源:update.cs


示例18: ASCIIReader

 public ASCIIReader(VTDGen enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
开发者ID:DuLerWeil,项目名称:vtd-xml,代码行数:4,代码来源:VTDGen.cs


示例19: FuncExpr

        public FuncExpr(int oc, Alist list)
        {
            a = 0;
            opCode = oc;
            argumentList = list;
            isBoolean_Renamed_Field = false;
            isString_Renamed_Field = false;
            isNodeSet_Renamed_Field = false;
            position = 0;
            //isNodeSet = false;
            isNumerical_Renamed_Field = false;
            argCount1 = argCount();
            switch (opCode)
            {

                case FuncName.LAST: isNumerical_Renamed_Field = true; break;

                case FuncName.POSITION: isNumerical_Renamed_Field = true; break;

                case FuncName.COUNT: isNumerical_Renamed_Field = true; break;

                case FuncName.LOCAL_NAME: isString_Renamed_Field = true; break;

                case FuncName.NAMESPACE_URI: isString_Renamed_Field = true; break;

                case FuncName.NAME: isString_Renamed_Field = true; break;

                case FuncName.STRING: isString_Renamed_Field = true; break;

                case FuncName.CONCAT: isString_Renamed_Field = true; break;

                case FuncName.STARTS_WITH: isBoolean_Renamed_Field = true; break;

                case FuncName.CONTAINS: isBoolean_Renamed_Field = true; break;

                case FuncName.SUBSTRING_BEFORE: isString_Renamed_Field = true; break;

                case FuncName.SUBSTRING_AFTER: isString_Renamed_Field = true; break;

                case FuncName.SUBSTRING: isString_Renamed_Field = true; break;

                case FuncName.STRING_LENGTH: isNumerical_Renamed_Field = true; break;

                case FuncName.NORMALIZE_SPACE: isString_Renamed_Field = true; break;

                case FuncName.TRANSLATE: isString_Renamed_Field = true; break;

                case FuncName.BOOLEAN: isBoolean_Renamed_Field = true; break;

                case FuncName.NOT: isBoolean_Renamed_Field = true; break;

                case FuncName.TRUE: isBoolean_Renamed_Field = true; break;

                case FuncName.FALSE: isBoolean_Renamed_Field = true; break;

                case FuncName.LANG: isBoolean_Renamed_Field = true; break;

                case FuncName.NUMBER: isNumerical_Renamed_Field = true; break;

                case FuncName.SUM: isNumerical_Renamed_Field = true; break;

                case FuncName.FLOOR: isNumerical_Renamed_Field = true; break;

                case FuncName.CEILING: isNumerical_Renamed_Field = true; break;

                case FuncName.ROUND: isNumerical_Renamed_Field = true; break;
                case FuncName.ABS: isNumerical_Renamed_Field = true; break;
                case FuncName.ROUND_HALF_TO_EVEN:
                    isNumerical_Renamed_Field = true; break;
                case FuncName.ROUND_HALF_TO_ODD:
                    isNumerical_Renamed_Field = true; break;
                case FuncName.CODE_POINTS_TO_STRING:
                    isString_Renamed_Field = true; break;
                case FuncName.COMPARE: isBoolean_Renamed_Field = true; break;
                case FuncName.UPPER_CASE: isString_Renamed_Field = true; break;
                case FuncName.LOWER_CASE: isString_Renamed_Field = true; break;
                case FuncName.ENDS_WITH: isBoolean_Renamed_Field = true; break;
                case FuncName.QNAME: isString_Renamed_Field = true; break;
                case FuncName.LOCAL_NAME_FROM_QNAME:
                    isString_Renamed_Field = true; break;
                case FuncName.NAMESPACE_URI_FROM_QNAME:
                    isString_Renamed_Field = true; break;
                case FuncName.NAMESPACE_URI_FOR_PREFIX:
                    isString_Renamed_Field = true; break;
                case FuncName.RESOLVE_QNAME: isString_Renamed_Field = true; break;
                case FuncName.IRI_TO_URI: isString_Renamed_Field = true; break;
                case FuncName.ESCAPE_HTML_URI: isString_Renamed_Field = true; break;
                case FuncName.ENCODE_FOR_URI: isString_Renamed_Field = true; break;
                case FuncName.MATCH_NAME: isBoolean_Renamed_Field = true; break;
                case FuncName.MATCH_LOCAL_NAME: isBoolean_Renamed_Field = true; break;
                case FuncName.NOT_MATCH_NAME: isBoolean_Renamed_Field = true; break;
                case FuncName.NOT_MATCH_LOCAL_NAME: isBoolean_Renamed_Field = true; break;
                case FuncName.GENERATE_ID: isString_Renamed_Field = true; break;
                case FuncName.FORMAT_NUMBER: isString_Renamed_Field = true; break;
                case FuncName.KEY: isNodeSet_Renamed_Field = true; state = START; vg = new VTDGen(); break;
                case FuncName.DOCUMENT: isNodeSet_Renamed_Field = true; state = START; vg = new VTDGen(); break;
                case FuncName.CURRENT: isNodeSet_Renamed_Field = true; state = START; vg = new VTDGen(); break;
                case FuncName.SYSTEM_PROPERTY: isString_Renamed_Field = true; break;
                case FuncName.ELEMENT_AVAILABLE: isBoolean_Renamed_Field = true; break;
                case FuncName.FUNCTION_AVAILABLE: isBoolean_Renamed_Field = true; break;
//.........这里部分代码省略.........
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:101,代码来源:FuncExpr.cs


示例20: readSeparateIndex

        public static void readSeparateIndex(System.IO.Stream index, System.IO.Stream XMLBytes, int XMLSize, VTDGen vg)
        {
            if (index == null || vg == null || XMLBytes == null)
            {
                throw new System.ArgumentException("Invalid argument(s) for readIndex()");
            }
            //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' 
            //which has a different behavior. 
            //"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
            System.IO.BinaryReader dis = new System.IO.BinaryReader(index);
            byte b = dis.ReadByte(); // first byte
            // no check on version number for now
            // second byte
            vg.encoding = dis.ReadByte();
            int intLongSwitch;
            int endian;
            // third byte
            b = dis.ReadByte();
            if ((b & 0x80) != 0)
                intLongSwitch = 1;
            //use ints
            else
                intLongSwitch = 0;
            if ((b & 0x40) != 0)
                vg.ns = true;
            else
                vg.ns = false;
            if ((b & 0x20) != 0)
                endian = 1;
            else
                endian = 0;
            if ((b & 0x1f) != 0)
                throw new IndexReadException("Last 5 bits of the third byte should be zero");

            // fourth byte
            vg.VTDDepth = dis.ReadByte();

            // 5th and 6th byte
            int LCLevel = (((int)dis.ReadByte()) << 8) | dis.ReadByte();
            if (LCLevel != 4 && LCLevel != 6)
            {
                throw new IndexReadException("LC levels must be at least 3");
            }
            // 7th and 8th byte
            vg.rootIndex = (((int)dis.ReadByte()) << 8) | dis.ReadByte();

            // skip a long
            dis.ReadInt64();
            //Console.WriteLine(" l ==>" + l);
            dis.ReadInt64();
            //Console.WriteLine(" l ==>" + l);
            long l = dis.ReadInt64();

            int size;
            // read XML size
            if (BitConverter.IsLittleEndian && endian == 0
                || BitConverter.IsLittleEndian == false && endian == 1)
                size = (int)l;
            else
                size = (int)reverseLong(l);


            // read XML bytes
            byte[] XMLDoc = new byte[size];
            XMLBytes.Read(XMLDoc, 0, size);

            //dis.Read(XMLDoc, 0, size);
            /*if ((size & 0x7) != 0)
            {
                int t = (((size >> 3) + 1) << 3) - size;
                while (t > 0)
                {
                    dis.ReadByte();
                    t--;
                }
            }*/

            vg.setDoc(XMLDoc);
            // skip a long
            dis.ReadInt64();
            //Console.WriteLine(" l ==>" + l);
            dis.ReadInt64();
            //Console.WriteLine(" l ==>" + l);
            if (BitConverter.IsLittleEndian && endian == 0
                || BitConverter.IsLittleEndian == false && endian == 1)
            {
                // read vtd records
                int vtdSize = (int)dis.ReadInt64();
                while (vtdSize > 0)
                {
                    vg.VTDBuffer.append(dis.ReadInt64());
                    vtdSize--;
                }
                // read L1 LC records
                int l1Size = (int)dis.ReadInt64();
                while (l1Size > 0)
                {
                    vg.l1Buffer.append(dis.ReadInt64());
                    l1Size--;
                }
//.........这里部分代码省略.........
开发者ID:IgorBabalich,项目名称:vtd-xml,代码行数:101,代码来源:IndexHandler.cs



注:本文中的com.ximpleware.VTDGen类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ximpleware.VTDNav类代码示例发布时间:2022-05-26
下一篇:
C# api.Session类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap