[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

splitting multiple occurrences of an element within an

Subject: splitting multiple occurrences of an element within another element
From: "Brian Benson" <bbenson@xxxxxxxxxxxx>
Date: Wed, 24 Sep 2003 12:39:43 -0500
dxl document
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.