Re: [xml] XSLT question, regarding RSS



On Apr 29, 2004, at 3:41 AM, Fabrice Desré FTR&D/DTL/TAL wrote:

Well, this is not an XSLT oddity, this is because XPath has no concept of a default namespace. For XPath, no prefix means no namespace, and not the default namespace of the stylesheet. What it means is that you have to declare a prefix for each and every namespace used in an XPath expression, even if the elements you want to select appear to be scoped by the default ns in the xml data.

I know the distinction between the two, and the solution. What I was trying to say is that while this distinction may be clear to XPath experts, it is not to XPath novices. The distinction is too subtle and it's confusing to many first time XSLT users.

See Section 2.0 and 2.1 from the XSLT 2.0 Requirements Working Draft (http://www.w3.org/TR/xslt20req):

2
Must Improve Ease of Use

XSLT 2.0 MUST address frequently requested enhancements to make using XPath even more straightfoward for handling common use cases.
        
2.1
Must Allow Matching on Default Namespace  Without Explicit Prefix

Many users stumble trying to match an element with a default namespace. They expect to be able to do something like:
        <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 xmlns="urn:myuri">

          <!-- Expect this matches <foo> in default namespace
        -->

          <xsl:template match="foo">

thinking that leaving off the prefix from the foo element name, that it will match <foo> elements in the default namespace with the URI of urn:myuri. Instead, they are required to assign a non-null prefix name to their namespace URI and then match on "someprefix:foo" instead, which has proven to be far from obvious. XSLT 2.0 SHOULD provide an explicit way to handle this scenario to avoid further user confusion.

I think "proven to be far from obvious" is pretty much standards-speak for "oops, maybe that wasn't a good design decision after all." :)

-adam

--
adam trachtenberg
adam trachtenberg com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]