Re: [xsl] are all strings in a sequence valid potential QNames

Subject: Re: [xsl] are all strings in a sequence valid potential QNames
From: ac <ac@xxxxxxxxxxxxx>
Date: Thu, 04 Feb 2010 22:02:03 -0500
Hi,

Regex work fine for the application at hand but that "castable as
xs:QName" is limited to literal strings and returns false in other
cases, seems a little counter intuitive and somewhat restrictive.
Consequently, I would tend to support Andrew's proposal that 2.1
reconsiders the issue.

What happens if I have
<xsl:variable name="str" select="ns:att"/>
and then do
<xsl:attribute name="{$str}" select="'something'"/>
while "ns:" is not specifically defined anywhere?

Is "ns:" assigned no namespace or the default namespace, either from the
context note or from the stylesheet, if no context node is currently
defined?

In any case, castable as QName should probably handle similarly.

Cheers,
ac


At 2010-02-04 16:46 +0000, Andrew Welch wrote:
> As has been told, "castable as" is not correct for this use case. As
> Mike suggests, I'll also go for a regex solution.

I would disagree, "castable as" is absolutely the correct approach in
this case (creating element names based on some input).

If an element name were only the prefix and local name, then sure ... but one isn't creating an element name, one is creating an element expanded name using an element qualified name.


However, it's not possible because of the (imho) unnecessary
restriction in the spec, so you are forced to fall back to a regex
based solution.

Currently even NCNames fail the castable xs:QName test, which has to be wrong.

Note that I included an NCName literal string in my illustration and it passed ... or are you referring to a string with an NCName value? A string with an NCName value would still be based on the default namespace of the unspecified node for context. In my illustration the default namespace was effectively null since there was no default namespace declaration.


Hopefully this could be looked at for 2.1...?

What would be the details of your proposal for a change? Would simply using the context node (and an error if the context item isn't a node) be enough?


. . . . . . . . . . . Ken


-- XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread