On the iReport documentation I found these XPath queries:
/addressbook/category@name
/addressbook/category/person@id
/addressbook/category/person+LASTNAME
/addressbook/category/person+FIRSTNAME
/addressbook/category/person+hobbies*hobby
My questions:
- Is
category@name
the same ascategory/@nam开发者_C百科e
? - What's the meaning of
person+LASTNAME
? (The + to be precise) - What's the meaning of
person+hobbies*hobby
(The * to be precise)
They are applied to this XML:
<addressbook>
<category name="home">
<person id="1">
<LASTNAME>Davolio</LASTNAME>
<FIRSTNAME>Nancy</FIRSTNAME>
<hobbies>
<hobby>Radio Control</hobby>
<hobby>R/C Cars</hobby>
<hobby>Micro R/C Cars</hobby>
<hobby>Die-Cast Models</hobby>
</hobbies>
<email>email1@my.domain.it</email>
<email>email2@my.domain2.it</email>
...
(Full XML here)
That's not XPath. It's just XPath-like. From the page that you linked:
<symbol>
is used to add an extra path to the base path and to define what should be returned.
+ add the following path to the base_path (this happen when the base_path = record path);
@ return the attribute value: it's followed by the attribute name;
* return all tags identified by the following path as a JRXMLDatasource
It's in section 7.3 of the link you have in your question.
So, going from that, these are the meanings of your XPath-like expressions:
/addressbook/category@name
The basepath is /addressbook/category, return the attribute "name"
/addressbook/category/person@id
The basepath is /addressbook/category/person, return the attribute "id"
/addressbook/category/person+LASTNAME
The basepath is /addressbook/category/person, return the element "LASTNAME"
/addressbook/category/person+FIRSTNAME
The basepath is /addressbook/category/person, return the element "FIRSTNAME"
/addressbook/category/person+hobbies*hobby
The basepath is /addressbook/category/person, look inside "hobbies"
and return all elements named "hobby"
精彩评论