[jdom-interest] SAXBuilder again [better formatting]

Mujahid Ali mujahid007 at home.com
Wed Aug 8 23:23:07 PDT 2001


Hi.

I have an xml document that contains sql queries in form of processing
instructions. 
I want to read in the document, run the queries contained by the PIs and
replace the PI 
with data returned by the queries. 

 

So if we have this:

<interface>
    <filter_criteria>
        <field name="test">
        <?query sql="SELECT * from x"?>
        </field>
        <field name="test2">
        <?query sql="SELECT * FROM y"?>
        </field>
      </filter_criteria>
</interface>

 

after processing the above document we would have 

 

<interface>
    <filter_criteria>
        <field name="test">
        <values>
            <value>1</value>
            <value>2</value>
        </values>
        </field>
        <field name="test2">
        <values>
            <value>1</value>
            <value>2</value>
        </values>
        </field>
      </filter_criteria>
</interface>

 

I can accomplish this by building my own Content Handler and capturing
the callbacks using SAX. So as I 
start to read the file using SAX, I can write another one out. So this
way the new file will contain the 
original xml structure + the new data fetched by the sql queries.

 

Alternatively,  I can use the SAXBuilder to build a JDOM document,
traverse through each element looking 
for PIs and handling them appropriately.

 

My question is if the xml file is really big, like let’s say 1 MB, which
way would be more efficient? I don’t really understand what a JDOM
Document is so hoping that maybe some one can help me out.

Regards,

Mujahid Ali




More information about the jdom-interest mailing list