XMLDoc size exceeds maximum size

Saraswathy
2010-10-24
2013-05-15
  • Saraswathy
    Saraswathy
    2010-10-24

    Hi ,

    I get the error  java.io.IOException: XMLDoc size exceeds maximum size when trying to insert attributes

    05:34:03,418 ERROR  XMLUtil.getXMLString failed with error message -:java.io.IOException: XMLDoc size exc
    eeds maximum size
    05:34:03,418 ERROR  java.io.IOException: XMLDoc size exceeds maximum size
    05:34:03,418 ERROR      at com.ximpleware.XMLByteOutputStream.write(XMLByteOutputStream.java:47)
    05:34:03,418 ERROR      at com.ximpleware.XMLModifier.output(XMLModifier.java:1510)

    Sample code snippet is

    try {

    XMLModifier xm1 = new XMLModifier(vn1);
    XMLModifier xm2 = new XMLModifier(vn2);

    AutoPilot apSocioAttributes = new AutoPilot(vn1);
    AutoPilot apRelatedTerms = new AutoPilot(vn2);

    apRelatedTerms.declareXPathNameSpace("autn", "http://schemas.autonomy.com/aci/");
    apRelatedTerms.selectXPath("/autnresponse/responsedata/autn:qs");
    apSocioAttributes.selectXPath("/autnresponse/responsedata/autn:field/autn:value");

    /*
    * Iterating through itemResults.xml and extracting the needed info
    */

    if (vn2.toElement(VTDNav.ROOT,  "autnresponse")) {
    if (vn2.toElement(VTDNav.NEXT_SIBLING,  "responsedata")){
    if (apRelatedTerms.evalXPath()!=-1)  {
    long efn = vn2.getElementFragment();
    while(ap1.evalXPath()!=-1) {
    xm1.insertAfterElement(vn2, efn);
    }
    }/
    }//responsedata
    }//au

    if (vn1.toElement(VTDNav.ROOT,  "autnresponse")) {
    if (vn1.toElement(VTDNav.NEXT_SIBLING,  "responsedata")){

    do {
    while (apSocioAttributes.evalXPath()!= -1){
    System.out.println("updating attr");
    xm1.insertAttribute(" plant='1' name='goal' " );
    }
    }while (vn1.toElement(VTDNav.NEXT_SIBLING,  "autn:value"));
    }
    }

    //print ouput xml
    System.out.println("output xml = " + getXMLString(xm1));
    } catch (Exception e) {
    e.printStackTrace();
    }

    private static String getXMLString(XMLModifier xm) {
    try {
    XMLByteOutputStream xbos = new XMLByteOutputStream(xm.getUpdatedDocumentSize());
    xm.output(xbos);
    return xbos.toString();
    } catch (Exception e) {
    }

    The xml1 is modified by inserting value from xml2 and adding some attributes.

    Initial xmls
    xml1
    <?xml version='1.0' encoding='UTF-8' ?>
    <autnresponse xmlns:autn='http://schemas.autonomy.com/aci/'>
    <action>GETQUERYTAGVALUES</action>
    <response>SUCCESS</response>
    <responsedata>
    <autn:field>
    <autn:name>PRDS/PRD/MP/MBAS/MBA</autn:name>
    <autn:number_of_values>6</autn:number_of_values>
    <autn:total_values>6</autn:total_values>
    <autn:value count="1">8A</autn:value>
    <autn:value count="1">D</autn:value>
    <autn:value count="11">O</autn:value>
    <autn:value count="24">S</autn:value>
    <autn:value count="1">V</autn:value>
    <autn:value count="1">W</autn:value>
    </autn:field>
    </responsedata>
    </autnresponse>

    xml2
    <autnresponse xmlns:autn='http://schemas.autonomy.com/aci/'>
    <action>GETQUERYTAGVALUES</action>
    <response>SUCCESS</response>
    <responsedata>
    <autn:qs>
    <autn:element pdocs="3" poccs="9" cluster="0" docs="3">REPAIR
    KIT FOR</autn:element>
    <autn:element pdocs="3" poccs="3" cluster="0" docs="3">TUNSTALL
    ASSOCIATES</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="1" docs="1">LENMAR
    PC911 CHARGER ADAPTER PLATE FOR</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="0" docs="1">REPAIR
    KIT FOR STRONG 11T</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="0" docs="1">REPAIR
    KIT FOR ERWEL 3</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="2" docs="1">ACCESS
    HARDWARE</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="3" docs="1">SERIAL
    CABLE</autn:element>
    <autn:element pdocs="1" poccs="1" cluster="2" docs="1">DESIGNED
    SECURITY</autn:element>
    </autn:qs>
    <autn:field>
    <autn:name>PRDS/PRD/MP/MBAS/MBA</autn:name>
    <autn:number_of_values>6</autn:number_of_values>
    <autn:total_values>6</autn:total_values>
    <autn:value count="1">8A</autn:value>
    <autn:value count="1">D</autn:value>
    <autn:value count="11">O</autn:value>
    <autn:value count="24">S</autn:value>
    <autn:value count="1">V</autn:value>
    <autn:value count="1">W</autn:value>
    </autn:field>
    </responsedata>
    </autnresponse>

    Please help.

    Thank you.
    Saraswathy.

     
  • jimmy zhang
    jimmy zhang
    2010-10-24

    do you have and are you using the absolute latest version?

     
  • Saraswathy
    Saraswathy
    2010-10-25

    The first time I ever came across VTD was 9/17/10 and coincidentally, I download the latest version which was released on 9/16/10 which was version 2.9 and that is the version I'm using.

    The only change I had to make was to recompile the jar for jdk1.5

    I'm not clear by what you mean about absolute version.

     
  • jimmy zhang
    jimmy zhang
    2010-10-25

    will look into it and get back asap…

     
  • jimmy zhang
    jimmy zhang
    2010-10-25

    your code logic seems a little inconsistent, can you put together a more complete test case?

     
  • Saraswathy
    Saraswathy
    2010-10-27

    Hi ,

    Here is my test case (main) class

    package com.csa.porter;

    import java.io.File;
    import java.io.FileInputStream;

    import org.junit.After;
    import org.junit.AfterClass;
    import org.junit.Before;
    import org.junit.BeforeClass;

    import com.ximpleware.AutoPilot;
    import com.ximpleware.VTDGen;
    import com.ximpleware.VTDNav;
    import com.ximpleware.XMLByteOutputStream;
    import com.ximpleware.XMLModifier;

    public class VTDtest {
    String output;
    public String testVtd() {
    try {

    VTDNav vn1 = createVTDNav("C://test/tv.xml");
    VTDNav vn2 = createVTDNav("C://test/sr.xml");
    XMLModifier xm1 = new XMLModifier(vn1);
    XMLModifier xm2 = new XMLModifier(vn2);
    AutoPilot ap1 = new AutoPilot(vn1);
    AutoPilot apSocioAttributes = new AutoPilot(vn1);
    AutoPilot apRelatedTerms = new AutoPilot(vn2);
    ap1.declareXPathNameSpace("autn", "http://schemas.autonomy.com/aci/");
    ap1.selectXPath("/autnresponse/responsedata/autn:number_of_fields");
    apRelatedTerms.declareXPathNameSpace("autn", "http://schemas.autonomy.com/aci/");
    apRelatedTerms.selectXPath("/autnresponse/responsedata/autn:qs");
    apSocioAttributes.selectXPath("/autnresponse/responsedata/autn:field/autn:value");
    /* * Iterating through itemResults.xml and extracting the needed info */
    if (vn2.toElement(VTDNav.ROOT, "autnresponse")) {
    if (vn2.toElement(VTDNav.NEXT_SIBLING, "responsedata")){
    if (apRelatedTerms.evalXPath()!=-1) {
    long efn = vn2.getElementFragment();
    while(ap1.evalXPath()!=-1) {
    xm1.insertBeforeElement(vn2, efn); }
    }

    }//responsedata
    }//au if (vn1.toElement(VTDNav.ROOT, "autnresponse"))

    if (vn1.toElement(VTDNav.ROOT,  "autnresponse")) {
    if (vn1.toElement(VTDNav.FIRST_CHILD,  "response")){
    if (vn1.toElement(VTDNav.NEXT_SIBLING, "responsedata")){
    do { while (apSocioAttributes.evalXPath()!= -1){
    System.out.println("updating attr");
    xm1.insertAttribute(" plant='1' name='goal' " );
    }
    }while (vn1.toElement(VTDNav.NEXT_SIBLING, "autn:value"));
    }
    }
    }

    //print ouput xml
    output = getXMLString(xm1);
    System.out.println("output xml = " + output);

    } catch (Exception e) { e.printStackTrace();
    }
    return output;
    }

    private static String getXMLString(XMLModifier xm) {
    try {
    XMLByteOutputStream xbos = new XMLByteOutputStream(xm.getUpdatedDocumentSize());
    xm.output(xbos);
    return xbos.toString();
    } catch (Exception e) {e.printStackTrace(); }
    return null;
    }

    private static VTDNav createVTDNav(byte ba)  {

    VTDGen vg = new VTDGen();
    VTDNav vn = null;       
    try {
    vg.setDoc(ba);
    vg.parse(true);
    vn = vg.getNav();
    }catch(Exception e) {e.printStackTrace();}
    return vn;
    }

    private static VTDNav createVTDNav(String filename) {

    File f = new File(filename);
    // counting child elements of parlist
    VTDNav vn = null;  
    try {
    FileInputStream fis = new FileInputStream(f);
    byte b = new byte;
    fis.read(b);
    VTDGen vg = new VTDGen();
    vg.setDoc(b);
    vg.parse(true);
    vn = vg.getNav();
    }catch(Exception e) {e.printStackTrace();}

    return vn;
    }

      public static void main(String args){
      VTDtest mytest = new VTDtest();
      System.out.println(mytest.testVtd());
       
    }

    }

    tv.xml

    <?xml version='1.0' encoding='UTF-8' ?>
    <autnresponse xmlns:autn='http://schemas.autonomy.com/aci/'>
    <action>GETQUERYTAGVALUES</action>
    <response>SUCCESS</response>
    <responsedata>
    <autn:number_of_fields>2</autn:number_of_fields>
    <autn:field>
    <autn:name>PRDS/PRD/MP/MEMS/MEM</autn:name>
    <autn:number_of_values>7</autn:number_of_values>
    <autn:total_values>7</autn:total_values>
    <autn:value count="13">AH</autn:value>
    <autn:value count="13">AI</autn:value>
    <autn:value count="13">AV</autn:value>
    <autn:value count="13">BC</autn:value>
    <autn:value count="21">RR</autn:value>
    <autn:value count="28">YY</autn:value>
    <autn:value count="8">ZZ</autn:value>
    </autn:field>
    <autn:field>
    <autn:name>PRDS/PRD/MP/MBAS/MBA</autn:name>
    <autn:number_of_values>6</autn:number_of_values>
    <autn:total_values>6</autn:total_values>
    <autn:value count="1">8A</autn:value>
    <autn:value count="1">D</autn:value>
    <autn:value count="11">O</autn:value>
    <autn:value count="24">S</autn:value>
    <autn:value count="1">V</autn:value>
    <autn:value count="1">W</autn:value>
    </autn:field>
    <autn:field>
    <autn:name>DOCS/DREDOC/DRECONTENT/SRVS/SRV/CATS/CAT</autn:name>
    <autn:number_of_values>0</autn:number_of_values>
    <autn:total_values>0</autn:total_values>
    </autn:field>
    <autn:engines>
    <autn:used>0,1,2,3</autn:used>
    <autn:unused>4</autn:unused>
    </autn:engines>
    </responsedata>
    </autnresponse>

    sr.xml

    <?xml version='1.0' encoding='UTF-8' ?>
    <autnresponse xmlns:autn='http://schemas.autonomy.com/aci/'>
    <action>QUERY</action>
    <response>SUCCESS</response>
    <responsedata>
    <autn:numhits>6</autn:numhits>
    <autn:totalhits>204</autn:totalhits>
    <autn:totaldbdocs>5566</autn:totaldbdocs>
    <autn:totaldbsecs>5566</autn:totaldbsecs>
    <autn:querysummary>HEWLETT PACKARD, ROLLER EXCHANGE KIT FOR, 5550
    input tray</autn:querysummary>
    <autn:spelling>paper</autn:spelling>
    <autn:spellingquery>( paper )</autn:spellingquery>
    <autn:qs>
    <autn:element pdocs="2" poccs="2" cluster="0" docs="2">HEWLETT
    PACKARD</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="0" docs="1">38
    CYAN PIGMENT INK CART</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="1" docs="1">ROLLER
    EXCHANGE KIT FOR</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="0" docs="1">200FT
    UNIVERSAL INSTANT-</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="2" docs="1">5550
    input tray</autn:element>
    <autn:element pdocs="1" poccs="1" cluster="3" docs="1">SOPORCEL
    NORTH AMERICA</autn:element>
    <autn:element pdocs="1" poccs="1" cluster="1" docs="1">PANASONIC
    CORPORATION</autn:element>
    <autn:element pdocs="1" poccs="3" cluster="0" docs="1">DRY
    GLOS</autn:element>
    </autn:qs>
    </responsedata>
    </autnresponse>

     
  • jimmy zhang
    jimmy zhang
    2010-10-27

    bug fixed, pls check out XMLModifier from cvs and compile… can you do that and verify?

     
  • Saraswathy
    Saraswathy
    2010-10-30

    Thank you very much.

    It works great now as I expected.

    I appreciate your timely and valuable help.

    Saraswathy.