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

Re: qName/localName confusion


xml qname localname
+1. I never remember my parsers attitude and keep checking for nulls in 
both local and qname... both should always be reported. If with a null 
namespace, qname and local name should be equal.

Karl Waclawek wrote:

> Since we are still not done with all the SAX issues:
> 
> here is another thing that has never been clear to me:
> 
> Docs for startElement say this:
> 
> <quote>
> This event allows up to three name components for each element:
> 
>   1.. the Namespace URI;
>   2.. the local name; and
>   3.. the qualified (prefixed) name.
> Any or all of these may be provided, depending on the values of the
> http://xml.org/sax/features/namespaces and the
> http://xml.org/sax/features/namespace-prefixes properties:
> 
>   a.. the Namespace URI and local name are required when the namespaces
>       property is true (the default), and are optional when the namespaces
>       property is false (if one is specified, both must be);
>   b.. the qualified name is required when the namespace-prefixes property
>       is true, and is optional when the namespace-prefixes property is false
>       (the default).
> </quote>
> 
> Strictly speaking that means that, when both features above are false,
> all three components - uri, localName, qName - are optional?
> And if I have a localName then an URI must be specified, based on a).
> 
> So, if there is no namespace defined, then  there is no URI and therefore
> localName must be empty, which leaves the qName. Now, if namespace processing
> is turned off, then qNames don't exist, but we also can't use the localName.
> So, one could say that in the absence of namespace processing qName = Name.
> But it is still optional.
> 
> This leaves me with this scenario - assuming namespace processing is turned on,
> but namespace-prefixes is turned off:
> - If the name is in a namespace, I will receive an URI and a localName,
>   but not necessarily a qName.
> - If the name is not in a namespace, I will not receive an URI and a localName,
>   but I should receive a qName (although strictly speaking it is optional).
> This forces me to have some checking logic even when I know how
> the features are set.
> 
> So far I have used this approach in the SAX2 adapter for Expat:
> Always provide a localName and qName, even if they are the same.
> I know, this contradicts a), but I am confused anyway.
> 
> The API would be easier to use if the three components provided
> were URI, localName and prefix. No confusion there.
> But considering the current API can't be changed, why not make
> the qName parameter required at all times, even if it is not
> required to contain the prefix?
> 
> Karl
> 
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 

-- 
Manos Batsis

     _  __    __                    __
    / |/ /__ / /____ __ _ ___ _____/ /_
   /    / -_) __(_-</  ' Y _ `/ __/ __/
  /_/|_/\__/\__/___/_/_/_|_,_/_/  \__/


http://www.netsmart.gr
mailto:mbatsisSPAM_TRAP@n...
tel:+302103240940
http://forte.netsmart.gr/foaf/manos_foaf.rdf



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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.