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

Re: Want to print elements/attrib specified by an XPat

Subject: Re: Want to print elements/attrib specified by an XPath that is passed as a param
From: Liam Quin <liam@xxxxxx>
Date: Mon, 15 Jun 2009 23:41:26 -0400
Re:  Want to print elements/attrib specified by an XPat
On Mon, Jun 15, 2009 at 08:04:48PM -0700, John Christopher wrote:
> 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.

[...]

There are three main approaches I can think of here.

(1) write an XSLT stylesheet that generates a new stylesheet in
which those XPath fragments (or template match patterns) are
in fact hard-coded...

(2) use the eval extension in an implementation that provides it

(3) interpret the XPath expression in XSLT.

E.g.
<xsl:template match="*">
  <xsl:param name="name" />

  <xsl:if test="localname() = $name">
     <xsl:message>got one!</xsl:message>
  </xsl:if>
  <xsl:apply-templates />
</xsl:template>

Well, this doesn't handle a/b, but you could use substring-after
to handle that, or, in XSLT 2, you could split the string on "/"
and then look for predicates, and you could do fancy things with count()
to sort into document rder & weed out duplicates.

But I'd favour approach (1) probably.

Liam

-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/ * http://www.fromoldbooks.org/

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.