[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] XPath - accessing nodes with a namespace with no prefix
Subject: Re: [xsl] XPath - accessing nodes with a namespace with no prefix From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx> Date: Sat, 5 Dec 2009 12:50:41 +0530 |
On Sat, Dec 5, 2009 at 4:51 AM, Philip Vallone <philip.vallone@xxxxxxxxxxx> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XPath - accessing nodes w, Philip Vallone | Thread | Re: [xsl] XPath - accessing nodes w, Mukul Gandhi |
Re: [xsl] Generic stylesheet to fla, C. M. Sperberg-McQue | Date | Re: [xsl] Nicer way to change conte, Mukul Gandhi |
Month |