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

Re: [saxon] Use of QName forcing declaration "Unused"

Subject: Re: [saxon] Use of QName forcing declaration "Unused" namespaces
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 21 Jul 2020 23:48:50 -0000
 Re: [saxon] Use of QName forcing declaration "Unused"
If the QNames are names of elements in the source document, then you shouldn't
be calling name() to get the lexical QName, and then calling xs:QName to turn
it back into an xs:QName value, because that loses information (specifically,
the namespace bindings that were in scope in the source document). Instead,
you should use the node-name() function to get the name as an xs:QName value
in the first place.

I may have misunderstood what's going on here, but I think this is the heart
of the issue: if you're going to manipulate QNames, then you need to get them
out of lexical format and into structured xs:QName format as early as
possible, while the original namespace bindings are still known.

Michael Kay
Saxonica

> On 21 Jul 2020, at 15:02, Ihe Onwuka <ihe.onwuka@xxxxxxxxx> wrote:
>
> Every element in my input doc is in one of  5 namespaces that I have
declared globally in the stylesheet. However the stylesheet as written never
explicitly references any of the 5 namespaces so  I would like to genericize
it by doing away with the namespace declarations.
>
> However if I remove any one of the namespaces I get this error.
>
> Error at char 79 in expression in xsl:sequence/@select on line 14 column 118
of ***.xsl:
>   FONS0004  Namespace prefix {jx} has not been declared
> at function local:localizedName on line 12 of ***.xsl:
>
> Here is the function local:localizedName which is designed to return  a
local name from a QName or a string.
>
> <xsl:function name="local:localizedName" as="xs:string?">
>       <xsl:param name="name"/>
>       <xsl:sequence select="local-name-from-QName(if ($name instance of
xs:QName) then $name else xs:QName($name))"/>
>    </xsl:function>
>
> It seems that casting anything as QName mandates that the namespace prefix
in whatever is being cast must be declared , even if it's not explicitly
referenced.
>
> e.g xs:string(xs:QName($someName)) will fail if $someName contains 'ab:cde'
and you haven't declared the ab prefix anywhere (even if you don't otherwise
use it).
>
> In which case my goal is better achieved by eradicating the QNames and
resorting to string manipulation to extract the local part of the name.
>
> Comments, observations, corrections please.
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/saxon-help

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.