java - JAXB - how to extract attribute value using MOXy XPath? -


This is my XML snippet. I used the Moxie JASAB extension to use XPath for direct access to those values. I am interested, about whom I am interested.

  & lt; GSP & gt; & Lt; RS & gt; & Lt; R = "1" & gt; & Lt; PageMap & gt; & Lt; DataObject Type = "Group" & gt; & Lt; Attribute name = "name" value = "some name" /> & Lt; Attribute name = "location" value = "miami, fl" /> & Lt; / DataObject & gt; & Lt; DataObject Type = "Organization" & gt; & Lt; Attribute name = "name" value = "ABC corp" /> & Lt; / DataObject & gt; & Lt; / PageMap & gt; & Lt; / R & gt; & Lt; R = "2" & gt; & Lt; PageMap & gt; & Lt; DataObject Type = "Group" & gt; & Lt; Attribute name = "name" value = "new name" /> & Lt; Attribute name = "location" value = "buys, id" /> & Lt; / DataObject & gt; & Lt; DataObject Type = "Organization" & gt; & Lt; Attribute name = "name" value = "IBM corp" /> & Lt; / DataObject & gt; & Lt; / PageMap & gt; & Lt; / R & gt; & Lt; / RES & gt; & Lt; / GSP & gt;   

I have the following mapping: first works, but the next two do not work.

  @XmlPath ("Pagemap / Data Object [@ type = 'group'] / attribute [@ name = 'location']") attribute groupLocation; @ XMLPath (@ PageMap / Data Object [@ type = 'group'] / attribute [@ name = 'name'] ") @ XML attribute (name =" value ") string group name; @ XMLPath ("Pagemap / Data Object [@ type = 'organization'] / attribute [@ name = 'name']") @ XML attribute (name = "value") string organization;   

}

In the case of the first one, the XML attribute has both names and types with my attribute object.

What am I doing wrong here? I was able to understand myself / I would have to use the value @ here. This is the right code here.

  @xmlPath ("Pagemap / Data Object [@ type = 'group'] / attribute [@ name = 'name'] / @ value") string group name; @ XMLPath (@Pememap / DataObact [@ type = 'organization'] / attribute [@ name = 'name'] / @ value ") @ XML attribute (name =" value ") string organization;    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -