[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] ID refs


Subject: RE: [xsl] ID refs
From: Jarno.Elovirta@xxxxxxxxx
Date: Mon, 19 Jan 2004 14:36:21 +0200

Hi,

> I have the following XML:
>  
>  
> <Specification_expression id="specification_expression-1">
>       <id>teste</id>
>       <description>teste</description>
>       <operation>or_operator</operation>
>       <operand>
>            <sos ref="sos-1"/>
>       </operand>
>  </Specification_expression>
>   
>  <sos id="sos-1">
>   <Specification ref="specification-7"/>
>  </sos>

I assume these two XML fragments exist in the same document. If so,

  <xsl:template match="sos[@ref]">
    <xsl:copy>
      <xsl:apply-templates select="//sos[@id = current()/@ref]/node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="sos[@id]"/>
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

Will get you there. If you have a DTD that defines the "id" attribute as an ID, then

  <xsl:apply-templates select="id(@ref)/node()"/>

Will also get you there-again, there are other ways, too.

Cheers,

Jarno - This Morn' Omina: One Eyed Man

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



Current Thread
  • [xsl] ID refs
    • Ricardo Saraiva - Mon, 19 Jan 2004 11:53:02 -0000
      • <Possible follow-ups>
      • Jarno . Elovirta - Mon, 19 Jan 2004 14:36:21 +0200 <=
Keywords
xml