xsl-list
[Top] [All Lists]

Re: transforming XML to XML with XSLT 1.0

2005-05-20 07:08:10

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:output indent="yes"/>
<xsl:key name="sm" match="Row" use="@SHORT_MESSAGE"/>
<xsl:template match="oda">
<oda>
<aid><xsl:value-of select="Row[1]/@AID"/></aid>
<group>
<type><xsl:value-of select="Row[1]/@GROUP_TYPE"/></type>
<version><xsl:value-of select="Row[1]/@GROUP_VERSION"/></version>
</group>
<timeout><xsl:value-of select="Row[1]/@TIMEOUT"/></timeout>
<xsl:for-each select="Row[generate-id()=generate-id(key('sm',@SHORT_MESSAGE))]">
<shortmessage><xsl:value-of select="@SHORT_MESSAGE"/></shortmessage>
</xsl:for-each>
<odaaccessrights>
<xsl:for-each select="Row">
<number><xsl:value-of select="position()"/></number>
<enabled><xsl:value-of select="@ACCESS_RIGHT"/></enabled>
</xsl:for-each>
</odaaccessrights>
</oda>
</xsl:template>

</xsl:stylesheet>



$ saxon oda.xml oda.xsl
<?xml version="1.0" encoding="utf-8"?>
<oda>
   <aid>CD46</aid>
   <group>
      <type>08</type>
      <version>A</version>
   </group>
   <timeout>2</timeout>
   <shortmessage>0066</shortmessage>
   <shortmessage>6280</shortmessage>
   <odaaccessrights>
      <number>1</number>
      <enabled>0</enabled>
      <number>2</number>
      <enabled>0</enabled>
      <number>3</number>
      <enabled>1</enabled>
   </odaaccessrights>
</oda>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>