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

position matching

Subject: position matching
From: "Ganesh Babu N" <nbabuganesh@xxxxxxxxx>
Date: Wed, 26 Nov 2008 16:21:54 +0530
 position matching
Hai All,

I am working on automatic XSLT generation project and here is the
mapping table.

Here is my XML file:
 <map>
      <source>article</source>
      <source>@docsubtype</source>
      <source>@version</source>
      <target>article</target>
      <target>@article-type</target>
      <target>@dtd-version</target>
   </map>

My stylesheet:

<xsl:template match="map">
<xsl:if test="count(child::source) = count(child::target) and
count(child::*) != 2">
<mac:template match="{source[1]}">
<mac:element name="{target[1]}">
<xsl:for-each select="target[position() > 2">
<mac:attribute name="substring-after({target},'@')"><mac:value-of
select="preceding-sibling::source[position()]"/></mac:attribute>
<xsl:for-each>
<mac:apply-templates select="@*|node()"/>
</mac:element>
</mac:template>
</xsl:if>
</xsl:template>

Expected Output:

<xsl:template match="article>
<xsl:element name="article">
<xsl:attribute name="article-type"><xsl:value-of
select="@docsubtype"></xsl:attribute>
<xsl:attribute name="@dtd-version"><xsl:value-of
select="@version"></xsl:attribute>
</xsl:element>
<xsl:template>


I am not getting the desired result. Please let me know where I am going wrong.

Regards,
Ganesh

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.