Platinum Partner

How To Create And Loading Index For XML Document Using VTD-XML?

This example has two applications that respectively generate VTD+XML index for XML, and load VTD+XML index (thus bypass parsing).

The code below indexes the XML documents



import com.ximpleware.*;
import java.io.*;
public class createIndex {
      public static void main(String[] args) throws Exception{
                     VTDGen vg = new VTDGen();
                     if (args.length != 2)
                             throw new Exception("Invalid # of arguments");

                     String inputName = args[0];
                     String outputName = args[1];

                     if (vg.parseFile(inputName,true)){
                        vg.writeIndex(new FileOutputStream(outputName));
                     }
       }
}


Below is the code for loading the index


import java.io.*;
import com.ximpleware.*;
public class loadIndex {
         public static void main(String[] args) throws IOException,IndexReadException {
                 VTDGen vg = new VTDGen();
                 VTDNav vn = vg.loadIndex(args[0]);
                // put the processing logic here 
        }
}
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}