[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] splitting multiple occurrences of an element within an
I am very new to xsl and really struggling to get the results that I want. I am trying to convert an xml file that looks like this ==================== <database> <document form='formname'> <noteinfo unid='abc'/> <doclink document='1'/> <doclink document='2'/> </document> </database> Into an xml file that looks like this ===================== </database> <document> <form>formname</form> <unid>abc</unid> <doclink>1</doclink> </document> <document> <form>formname</form> <unid>abc</unid> <doclink>2</doclink> </document> </database> The xslt that I have so far works well, except for the following: 1) If there is more than one doclink in one document, they need to be split into multiple documents so that there is one doclink per document. The xsl below puts all doclinks in one document. 2) The form and unid attributes are output as attributes and they need to be converted to elements. I have been able to get both of the above to work, but not at the same time. Any help is appreciated. The xslt that I have so far looks like this: ===================== <xsl:template match="/"> <database> <xsl:apply-templates/> </database> </xsl:template> <xsl:template match="dxl:document"> <document> <xsl:copy-of select="@form | dxl:noteinfo/@unid |.//dxl:doclink"/> </document> <xsl:apply-templates/> </xsl:template> <!-- remove all other text and attributes --> <xsl:template match ="text()|@*"></xsl:template> <!-- remove all documents with no doc links --> <xsl:template match ="dxl:document[not(.//dxl:doclink)]"></xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|