Hello all.
First of all, I'm very new to XML, XSLT, JAXB and Java.
Please forgive me if i'm asking a dumb question.
I would really appreciate any pointers to information you could give me.
I have been searching in google for days, but can't find anything useful.
Sorry in advance for such a long message.
INTRODUCTION:
I have an XSD file that I converted into classes using JAXB. The XML
generated files (invoices) are just fine in order to send information to
the other party.
Now I need to print (in paper) the invoices. I thought I could use XSLT
to "transform" the xml, but I need to add some more information not
included in the xml file. That extra information isn't always the same,
not even their the attribute names.
PROBLEM:
So I thought I could create a second xml with "some" structure
containing that extra information that the XSLT script should be able to
merge with the original xml. (Maybe with the "document()" XSLT functin).
When I need to get some data of the invoice header I've got no problem.
I always can do someting like:
--- BEGIN ------------------------
<xsl:value-of
select="document('extra.xml')/ComprobanteExtraData/Receptor/_at_codcli"/>
--- END --------------------------
The problem I'm facing now is that I haven't been able to get
information from the detail part of the invoice. The "detail" nodes from
the original xml that represent all the product details have no unique
id, and the extra.xml file doesn't either (but the extra.xml can be
changed as I need).
WHAT I HAVE THOUGHT ABOUT IT:
I was thinking to add an id to the detail section of the extra.xml and
add somehow a counter to the for-each part of the XSLT.
I got nowhere. It's kind of difficult to "create" an XML by hand. More
if I know I could use JAXB in some way.
So I thought I should be able to generate an xml with basically the same
classes generated by the xsd, but to be able to add arbitrary name-value
pairs to those nodes instead of the ones generated from the original
xsd. That way I think I should be able to merge easily the main xml with
the extra.xml to transform it to a printable format (maybe html)
I don't know how to do something like this... don't know how to add
arbitrary name-value pairs (or attributes) to classes. The only way I
can think of is a List that contains a LinkedList.... something like:
--- BEGIN ------------------------
List<String> datos = new LinkedList<String>();
--- END --------------------------
But I have no idea of how to transform it to XML or to maintain the
original XML structure easily. Or even if it's a good idea to do it this
way.
If anybody has a tutorial, or has any pointers about how to solve this I
would really appreciate it.
Thanks a lot.
Ely