On Sat, Dec 5, 2009 at 4:51 AM, Philip Vallone
<philip(_dot_)vallone(_at_)verizon(_dot_)net> wrote:
(3) It's possible to select a node by using local-name() in a predicate with
a wild card e.g. //*[local-name()='title']. however, this may give me the
wrong result. I wasn't sure if there was another way
With XSLT 1.0, I would do this something like following:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xx="http://www.imsglobal.org/xsd/imscp_v1p1"
version="2.0">
<xsl:variable name="titleVal"
select="/xx:organizations/xx:organization/xx:item[2]/xx:title" />
<xsl:value-of select="$titleVal" />
With, XSLT 2.0 I might prefer (this solution won't need the namespace
declaration for, XML namespace http://www.imsglobal.org/xsd/imscp_v1p1
on xsl:stylesheet instruction):
<xsl:variable name="titleVal" select="/organizations/organization/item[2]/title"
xpath-default-namespace="http://www.imsglobal.org/xsd/imscp_v1p1" />
<xsl:value-of select="$titleVal" />
Such a facility in XSLT 2.0 allows us to have the
xpath-default-namespace, syntax local to any XSLT 2 instruction,
making the stylesheet design more flexible.
The attribute, xpath-default-namespace can also be global to the
stylesheet (i.e, present on xsl:stylesheet instruction, where it get's
available to the whole of stylesheet).
Just also to mention, xpath-default-namespace can be specified in an
inheritable fashion within the stylesheet, where the descendant XSLT 2
instructions can override, the xpath-default-namespace value present
on the ancestor element.
--
Regards,
Mukul Gandhi
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--