Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > [XSLT] Select node by attribute with value from an attribute of its self

Reply
Thread Tools

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

 
 
Stefan_W Stefan_W is offline
Junior Member
Join Date: Nov 2008
Posts: 2
 
      11-04-2008
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
 
Reply With Quote
 
 
 
 
Stefan_W Stefan_W is offline
Junior Member
Join Date: Nov 2008
Posts: 2
 
      11-05-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Its a bird, its a plane, its.. um, an Attribute based System? thunk Ruby 14 04-03-2010 10:08 AM
Its a bird, its a plane, its.. um, an Attribute based System? thunk Ruby 0 04-01-2010 10:25 PM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
Select Node Using position or value of another node. Eddy C XML 6 10-17-2005 11:02 PM
XSL HOWDOI use attribute of current node to select a different node? CB XML 1 10-02-2003 02:37 PM



Advertisments