xsl-list
[Top] [All Lists]

RE: ID refs

2004-01-19 05:36:21
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[(_at_)ref]">
    <xsl:copy>
      <xsl:apply-templates select="//sos[(_at_)id = current()/@ref]/node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="sos[(_at_)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



<Prev in Thread] Current Thread [Next in Thread>
  • ID refs, Ricardo Saraiva
    • RE: ID refs, Jarno . Elovirta <=