commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Russell Simpkins" <>
Subject how to load xml during parse
Date Thu, 29 Sep 2005 17:47:33 GMT

I'm having slight difficulty determining how to use digester to do more 
advanced hidrating of my beans. I have an xml file like this

<?xml version="1.0" encoding="UTF-8"?>
        <siteId external="false" id="true" type="long" 
        <title external="false" id="false" type="java.lang.String" 
                <Server row="0" id="3" type="media" 
                <Server row="1" id="4" type="media" 
                <Server row="2" id="5" type="media" 

My java bean has an ArrayList named servers with get/set/add methods. What I 
wanted to do was hydrate each Server object with the data in 
/Server/5/Server.5.xml for instance, based on what is in 
Site/Servers/Server. I can keep my XML documents smaller if I source the 
data rather then have all of the the data in the <Server> XML document.

I was hoping to do this with Digester rules:
<?xml version="1.0"?>
   <object-create-rule pattern="Site" classname="com.fg.fgcms.Site" />
   <bean-property-setter-rule pattern="Site/siteId" propertyname="siteId" />
   <bean-property-setter-rule pattern="Site/title" propertyname="title" />
   <pattern value="Site/Servers/Server">
      <object-create-rule classname="com.fg.fgcms.Server" />
      <set-next-rule methodname="addServer" />

Using XPATH one would simply call the document() function to get at the 
nested XML data. I am not sure how I can do this with digester or with the 
digester rules option.

Can you offer any direction or help? It would be greatly appreciated.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message