commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Worley Kevin" <Kevin.Wor...@tetrapak.com>
Subject [Digester] How can I 'shortcut' a parse?
Date Sun, 01 May 2005 17:27:44 GMT
Howdy,

I would like to know if anyone can tell me how to 'shortcut' a parse.

The XML file that I need to parse does not use Namespaces, but the rules
I need to use vary based on information in the "header" section.
Basically, the file is something like:

<bulkdata>
  <header>
    <PayloadID>X956487</PayloadID>
    <GenDate>1967-08-13</GenDate>
    <Mode>ABC</Mode>
    <ContactEmail>name@domain.com</ContactEmail>
    <SupplierID>A123456789B</SupplierID>
  </header>
  <body>
    <LineItem LineNumber="0">
      <ID>
        <Supplier>XYX Corp.</Supplier>
        <SupplierGroup>Group a</SupplierGroup>
        <ReferenceID>6565656</ReferenceID>
        <EmployeeName>John Doe</EmployeeName>
        <EmployeeNumber>123</EmployeeNumber>
        <BLNumber>AW54645664Z</BLNumber>
        <AWB>456789456</AWB>
        <HAWB>456789789</HAWB>
      </ID>
	...
    </LineItem>
  </body>
</bulkdata>

The 'body' can consist of thousands of 'LineItem' elements which are
each much more extensive than shown here.  Currently, I use Digester
with rules to parse the header.  When complete, I can look at what was
returned and set the rules to correctly parse the 'body' of the file.
This works, but requires the digester to completely parse the file
twice.  I'd really like to avoid doing it this way.

Does anyone know of a way I can have the parser simply end after the
'header' section is parsed?  

Thanks,

Kevin


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message