Re: Building a new tree

Subject: Re: Building a new tree
From: Nantapon Chaimunkong <b38npc@xxxxxxxx>
Date: Wed, 14 Apr 1999 00:21:39 +0700 (GMT)
You must identify id element using xsl:id before using id().

I try the following stylesheet. It doesn't work on XT, though. XT doesn't
support id.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"; indent-result-"yes">
<xsl:id attribute="id"/>

<xsl:template match="common"/>

<xsl:template match="/">
  <xsl:apply-templates select=".//letter"/>
</xsl:template>

<xsl:template match="letter//*|common//*">
  <xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>

<xsl:template match="letter//insert_common|common//insert_common">
 <xsl:apply-templates select="id(@ref)/*"/>
</xsl:template>

</xsl:stylesheet>


On Tue, 13 Apr 1999, Bovone Stefano wrote:

> I have, for example, the following XML document:
> 
> <?xml version="1.0"?>
> 
> <document>
> 	<common id="D1">
> 	  <p>First common part A</p>
> 	  <p>First common part b</p>
>             </common>
> 
> 	<common id="D2">
> 	  <title>SECOND COMMON PART</title>
> 	</common>
> 
> 	<letter>
> 	  <doc>
> 	  <title> THE DOCUMENT </TITLE>
> 	  <p> generic text</p>
> 	  <insert_common ref="D1"/>
> 	  <p> generic text</p>
> 	  <insert_common ref="D2"/>
>               </doc>
>              </letter>
> </document>
> 
> and I want using a XSL document to have:
> 
> <?xml version="1.0"?>
>   <doc>
> 	  <title> THE DOCUMENT </TITLE>
> 	  <p> generic text</p>
> 	  <p>First common part A</p>
> 	  <p>First common part b</p>
> 	  <p> generic text</p>
> 	  <title>SECOND COMMON PART</title>
>    </doc>
>              
> I thought to use:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http:/www.w3.org/TR/WD-xsl">
> 
> <xsl:template match="/">
>  <xsl:template select=".//letter"/>
> </xsl:template>
> 
> <xsl:template match="letter">
>   <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="letter/* | letter//*">
>  <xsl:copy>
>   <xsl:apply-templates select="text() | @* | * | ./* | insert_common"/>
>  </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="insert_common">
>   <xsl:apply-templates select="id(@ref)/tag"/>
> </xsl:template>
> 
> <xsl:template match="tag/*">
>  <xsl:copy>
>   <xsl:apply-templates select="text() | * | ./*"/>
>  </xsl:copy>
> </xsl:template>
> 
> </xsl:stylesheet>	
> 
> 
> but it doesn't work.
> 
> Have anybody any idea ?
> 
> Thanks. Bye.
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread