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

Joined
Nov 4, 2008
Messages
2
Reaction score
0
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 :)
 
Joined
Nov 4, 2008
Messages
2
Reaction score
0
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 :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top