I want to transform an XML document into RTF. The RTF side is no problem, but the XML document varies constantly in respect of the element names. For example:
<REQUEST>
<REQUEST_DETAIL>
<REQ_TYPE>P</REQ_TYPE>
<DOC_NAME>TEST</DOC_NAME>
<DOC_PATH>C:\PRINTDOC\TEST.DOC</DOC_PATH>
</REQUEST_DETAIL>
<REQUEST_DATA>
<DATA>
<KEY>234</KEY>
<FNAME>MARY</FNAME>
<SURNAME>BROWN</SURNAME>
</DATA>
<DATA>
<KEY>123</KEY>
<FNAME>JOHN</FNAME>
<SURNAME>SMITH</SURNAME>
</DATA>
</REQUEST_DATA>
</REQUEST>
In this case the resulting format I need is as follows:
KEY,FNAME,SURNAME
234,MARY,BROWN
123,JOHN,SMITH
and this would be fine if the elements always had the same names. But in another example where the elements were as follows:
<DATA>
<KEY>123</KEY>
<COMPANYNAME>XYZ INC</COMPANYNAME>
<CONTACT>JOHN SMITH</CONTACT>
</DATA>
How could I use the same XSLT. I have tried doing this and suspect that I may need to use the "name()" function but I cannot get it right.
The basics of the issue are that for any XML document the REQUEST, REQUEST_DETAIL, REQUEST_DATA and DATA element names always exist. The elemnt names within the DATA element can change from document to document. The result I need is the first line containing the element names within the DATA element and then the actual values for each of those elements for each DATA element in the document.
I think....
<REQUEST>
<REQUEST_DETAIL>
<REQ_TYPE>P</REQ_TYPE>
<DOC_NAME>TEST</DOC_NAME>
<DOC_PATH>C:\PRINTDOC\TEST.DOC</DOC_PATH>
</REQUEST_DETAIL>
<REQUEST_DATA>
<DATA>
<KEY>234</KEY>
<FNAME>MARY</FNAME>
<SURNAME>BROWN</SURNAME>
</DATA>
<DATA>
<KEY>123</KEY>
<FNAME>JOHN</FNAME>
<SURNAME>SMITH</SURNAME>
</DATA>
</REQUEST_DATA>
</REQUEST>
In this case the resulting format I need is as follows:
KEY,FNAME,SURNAME
234,MARY,BROWN
123,JOHN,SMITH
and this would be fine if the elements always had the same names. But in another example where the elements were as follows:
<DATA>
<KEY>123</KEY>
<COMPANYNAME>XYZ INC</COMPANYNAME>
<CONTACT>JOHN SMITH</CONTACT>
</DATA>
How could I use the same XSLT. I have tried doing this and suspect that I may need to use the "name()" function but I cannot get it right.
The basics of the issue are that for any XML document the REQUEST, REQUEST_DETAIL, REQUEST_DATA and DATA element names always exist. The elemnt names within the DATA element can change from document to document. The result I need is the first line containing the element names within the DATA element and then the actual values for each of those elements for each DATA element in the document.
I think....