[XSLT] Select node by attribute with value from an attribute of its self

Discussion in 'XML' started by Stefan_W, Nov 4, 2008.

  1. Stefan_W

    Stefan_W

    Joined:
    Nov 4, 2008
    Messages:
    2
    Hello,

    i'm a little bit stuck with xslt and xquery.

    Here is my problem, starting with showing the problem:

    My xml looks like this
    Code:
    <styles>
    <style name="_Ausgabe" src="css/_Ausgabe.css">
    	<!-- DarĂ¼ber steht fest als Text: "Patientenkennung" -->
    	<juxtaposed>
    		<slotDescriptor name="digit0" type="text" class="Text Digit"/>
    		<slotDescriptor name="digit1" type="text" class="Text Digit"/>		
    		<slotDescriptor name="digit2" type="text" class="Text Digit"/>
    		<slotDescriptor name="digit3" type="text" class="Text Digit"/>
    	</juxtaposed>
    </style>
    
    <style name="Administration" src="css/Administration.css">
    	<juxtaposed>
    		<stacked>
    			<copy ref="_Ausgabe"/>
    			<copy ref="_3erWahl"/>
    		</stacked>
    	</juxtaposed>
    </style>
    </styles>
    My problem actually is to resolve the copies within the xml.
    As you see there is a style named "_Ausgabe" and there is a copy tag with referers to this. Now i need to copy the whole "_Ausgabe" style to the copy tag position.

    Here is the xsl code
    Code:
    <xsl:template match="copy">
        <xsl:copy-of select="/child::styles/child::style[attribute::name=self[attribute::ref]]" />
    </xsl:template>
    But as you might know, it doens't work!
    How can i address a node by an attribute which value is determined by an attribute of the currently processed node? (Addressing style node by attribute "name" with the value of the current copy node attribute "ref")


    Sorry for this crappy explanation.

    Hope someone might help me :)
     
    Stefan_W, Nov 4, 2008
    #1
    1. Advertising

  2. Stefan_W

    Stefan_W

    Joined:
    Nov 4, 2008
    Messages:
    2
    Ok Guys,

    i solved it :)

    Code:
    <xsl:template name="main">
        <xsl:param name="selectStatement" />
        <xsl:apply-templates select="/styles/style[@name=$selectStatement]" />
    </xsl:template>
    
    <xsl:template match="copy">
        <xsl:call-template name="main">
            <xsl:with-param name="selectStatement" select="@ref" />
        </xsl:call-template>
    </xsl:template>
    
    Should be self-explanatory :)
     
    Stefan_W, Nov 5, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CB
    Replies:
    1
    Views:
    593
    Johannes Koch
    Oct 2, 2003
  2. Ralf W. Grosse-Kunstleve
    Replies:
    16
    Views:
    596
    Lonnie Princehouse
    Jul 11, 2005
  3. njsimha
    Replies:
    0
    Views:
    786
    njsimha
    Sep 16, 2008
  4. thunk
    Replies:
    0
    Views:
    496
    thunk
    Apr 1, 2010
  5. thunk
    Replies:
    14
    Views:
    630
    thunk
    Apr 3, 2010
Loading...

Share This Page