|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Want to print elements/attrib specified by an XPath th
My goal: I want an XSLT stylesheet that displays the contents of any element or attribute whose name I pass to the stylesheet as an XPath via a param. The important thing is, the stylesheet should work with any input XML, and should be able to print any matching elements or attributes, depending on the XPath I pass as a param. The XPath cannot be hardcoded in the stylesheet. For example, if I have the following XML file as input: <rolodex> <entry id="S"> <name>Smith, Dave</name> <phone>111-222-3333</phone> </entry> <entry id="W"> <name>Wilson, Mary</name> <phone>222-333-4444</phone> </entry> <entry id="E"> <name>Edwards, Paula</name> <phone>333-444-5555</phone> </entry> </rolodex> I want to pass the XPath "/rolodex/entry/name" as a param to the stylesheet, and have the stylesheet print: Smith, Dave Wilson, Mary Edwards, Paula If I pass the XPath "/rolodex/entry/@id" as a param to the stylesheet, the stylesheet should print: S W E So far, my stylesheet looks like this (see below). What am I doing wrong? Thanks in advance for your help. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:param name="xpath"/> <!-- ################################################## --> <xsl:template match="/"> <!-- value of xpath is <xsl:value-of select="$xpath"/> --> <xsl:apply-templates match="$xpath"/> </xsl:template> <!-- ################################################## --> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








