comp.text.xml
[Top] [All Lists]

Re: simplifying transform

Subject: Re: simplifying transform
From: Martin Honnen
Date: Wed, 23 Jul 2008 18:44:33 +0200
Newsgroups: comp.text.xml


David Schwartz wrote:
Actually, both stylesheets produce a file with the same number of
elements. The stylesheet you provided David does include the
attributes though so thanks!

So, now that I'm successfully creating all the tags, how do I change
the values of the ref attribute in just the tagC elements?

As suggested earlier:

<xsl:template match="@* | node()">

           <xsl:copy>
             <xsl:apply-templates select="@* | node()"/>
           </xsl:copy>

     </xsl:template>

 <xsl:template match="/">
        <redirect:write file="transformed.xml">

             <xsl:apply-templates/>

    </redirect:write>
     </xsl:template>

    <xsl:template match="@id2"/>

    <xsl:template match="tagC">
      <xsl:copy>
        <xsl:attribute name="ref">
          <xsl:value-of select="../*[@id2 = current()/@ref]/@id1"/>
        </xsl:attribute>
        <xsl:apply-templates/>
      </xsl:copy>
    </xsl:template>



--

        Martin Honnen
        http://JavaScript.FAQTs.com/

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