[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

call-template according to @ value, storing XPath in x

Subject: call-template according to @ value, storing XPath in xml
From: r holmes <xsl_question@xxxxxxxxxxxx>
Date: Fri, 7 Nov 2003 13:25:47 +1100 (EST)
xpath value
Could XSL transform;
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<display>
	<element n="100"/>
	<element n="101">
		<itemproperty pname="type" pvalue="textbox"/>
		<itemproperty pname="size" pvalue="10"/>	
		<itemproperty pname="name" pvalue="currency"/>				
		<itemproperty pname="xpath"
pvalue="/root/data/row/@curr"/>


	</element>
	<element n="102">
		<itemproperty pname="type" pvalue="hidden"/>	
		<itemproperty pname="name" pvalue="currency_value"/>
	
		<itemproperty pname="xpath"
pvalue="/root/data/row/@curr"/>

	</element>
</display>
<data>
	<row curr="USD"  currval="100"/>

</data>
</root>

-------------------------------------------------------

..to..

-------------------------------------------------------
<input type="text" name="currency" value="USD"/>
<input type="hidden" name="currency_value"
value="$100.00"/>
-------------------------------------------------------
..something along the lines of..

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:template match="/">
		<xsl:apply-templates
select="/root/display/element"/>
	</xsl:template>
	<xsl:template match="/root/display/element">
		<xsl:call-template
name="call_the_template_with_the_same_name_as_the_type_attribute">
			<xsl:with-param
name="node_tree">pass_node_tree_here</xsl:with-param>
		</xsl:call-template>
	</xsl:template>
	<xsl:template name="textbox">
		<xsl:param name="node_tree"/>
		<xsl:variable name="size" value="$node_tree/size"/>
		<xsl:variable name="name" value="$node_tree/name"/>
		<xsl:variable name="xpath"
value="$node_tree/xpath"/>
		<input type="text" name="{$name}"
value="{get_the_result_of_$xpath_here}"/>
	</xsl:template>
	<xsl:template name="hidden">
		<xsl:param name="node_tree"/>
		<xsl:variable name="name" value="$node_tree/name"/>
		<xsl:variable name="xpath"
value="$node_tree/xpath"/>
		<input type="hidden" name="{$name}"
value="{get_the_result_of_$xpath_here}"/>
	</xsl:template>
</xsl:stylesheet>
-------------------------------------------------------
..I guess there are 2 issues here..

1 - calling a template with the name which equals an
attribute value, and 

2 - writing out the value of an Xpath which is itself
stored as an value in an attribute

If not, can I restructure the XML in a way that it
could be done?

Any suggestions appreciated

Russ



http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.