Subject: [xsl] 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) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: XSL-List Digest V4 #1774, constantin . vasiliu | Thread | [xsl] Re: call-template according t, Dimitre Novatchev |
[xsl] RE: XSL-List Digest V4 #1774, constantin . vasiliu | Date | [xsl] Filtering with multiple templ, Dongling Ding |
Month |