Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Namespace Attributes

Reply
Thread Tools

Namespace Attributes

 
 
geoff
Guest
Posts: n/a
 
      12-03-2007
In the following fragment, elements like 'item' and 'description' would be
in the 'po' namespace but the attribute 'priority="high" ' would be in the
'p' namespace?

<poo id="43871"
submitted="2004-01-05"
customerId="73852"
xmlnso="http://www.skatestown.com/ns/po"
xmlns="http://www.skatestown.com/ns/priority">
. . .
<porder>
<item sku="318-BP" quantity="5" priority="high">
<description>Skateboard backpack; five
pockets</description>

.. . . so, if an order processor could handle this xml and later on,
'priority' was added, this would not break the processor since priority is
in its own namespace?

Thanks.

--g




 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-03-2007
geoff wrote:
> In the following fragment, elements like 'item' and 'description' would be
> in the 'po' namespace but the attribute 'priority="high" ' would be in the
> 'p' namespace?
>
> <poo id="43871"
> submitted="2004-01-05"
> customerId="73852"
> xmlnso="http://www.skatestown.com/ns/po"
> xmlns="http://www.skatestown.com/ns/priority">
> . . .
> <porder>
> <item sku="318-BP" quantity="5" priority="high">
> <description>Skateboard backpack; five
> pockets</description>
>
> . . . so, if an order processor could handle this xml and later on,
> 'priority' was added, this would not break the processor since priority is
> in its own namespace?


item and description element are in no namespace in your snippet. The
sku and quantity attribute are in no namespace, the priority attribute
is in the http://www.skatestown.com/ns/priority namespace.





--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      12-03-2007
In article <IpX4j.54803$(E-Mail Removed)>,
geoff <(E-Mail Removed)> wrote:

>In the following fragment, elements like 'item' and 'description' would be
>in the 'po' namespace but the attribute 'priority="high" ' would be in the
>'p' namespace?
>
> <poo id="43871"
> submitted="2004-01-05"
> customerId="73852"
> xmlnso="http://www.skatestown.com/ns/po"
> xmlns="http://www.skatestown.com/ns/priority">
> . . .
> <porder>
> <item sku="318-BP" quantity="5" priority="high">
> <description>Skateboard backpack; five
>pockets</description>


No, item and description are in no namespace.

>. . . so, if an order processor could handle this xml and later on,
>'priority' was added, this would not break the processor since priority is
>in its own namespace?


Using namespaced attributes is certainly a way to add attributes whose
interpretation does not come from the element they're on, provided
that your schema (or whatever) allows such other-namespace attributes.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
geoff
Guest
Posts: n/a
 
      12-03-2007
With priority and the priority attribute gone, only the 'po' namespace
remains in the 'poo' element, does item and description fall into that
namespace or they are still not in any namespace?

>> <poo id="43871"
>> submitted="2004-01-05"
>> customerId="73852"
>> xmlnso="http://www.skatestown.com/ns/po"
>> . . .
>> <porder>
>> <item sku="318-BP" quantity="5" >
>> <description>Skateboard backpack; five
>>pockets</description>



--g


 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      12-03-2007
geoff wrote:
> With priority and the priority attribute gone, only the 'po' namespace
> remains in the 'poo' element, does item and description fall into that
> namespace or they are still not in any namespace?


If an element or attribute does not have a prefix, and (for elements
only) is not in the scope of a Default Namespace Declaration, the
element or attribute is not in any namespace.

See the namespaces spec or a good modern XML tutorial.


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
geoff
Guest
Posts: n/a
 
      12-04-2007
> See the namespaces spec or a good modern XML tutorial.

I thought I was using a good tutorial, 'Building Web Services with Java',
and amazon reviewers praised this book but it appears to have many errors.

The snippet below had 'po' in front of 'billTo', 'shipTo', 'order', etc. but
they say by moving the 'po' namespace definition to the 'poo' element, the
child elements fall into that namespace:

http://87.249.105.167/mirror/buildin...tml#ch02list08


================================================

'We can use this to further clean up the composed XML document
by moving the PO namespace declaration to the po element

Listing 2.8 Using Nested Namespace Defaulting'

<message from="(E-Mail Removed)" to="(E-Mail Removed)"
sent="2001-10-05" xmlns="http://www.xcommercemsg.com/ns/message">
<text>
Hi, here is what I need this time. Thx, BJ.
</text>
<attachment>
<description>The PO</description>
<item>
<poo id="43871" submitted="2001-10-05"
xmlnso="http://www.skatestown.com/ns/po">
<billTo id="addr-1">
...
</billTo>
<shipTo href="addr-1"/>
<order>
...
</order>
</poo>
</item>
</attachment>
</message>





 
Reply With Quote
 
geoff
Guest
Posts: n/a
 
      12-04-2007
The book, 'Building Web Services with Java', has nine authors, here is
the background of one of them (from the book):

'Paul Fremantle is a Senior Technical Staff Member in IBM's Software
division, based in the Hursley Park laboratory near Winchester in England.
Paul works on IBM's Enterprise Service Bus initiative and other Web services
activities in the WebSphere product. Paul has been working on Web services
and XML at IBM since 1999, when he wrote early XML utilities for IBM's
alphaWorks website. Since then he has co-authored The XML Files, an IBM
redbook, as well as a number of articles on J2EE and Web services both in
print and on the Web. Paul's involvement on the WebSphere Application Server
includes architectural responsibility for the first SOAP support, the Web
Services Invocation Framework, and the Web Services Gateway. Paul is the
co-lead of the JWSDL standard in the Java Community Process and has
initiated two open-source projects. Paul has an MSc in computation and an MA
in mathematics and philosophy, both from Balliol College, Oxford.'


.. . . given a background like that, one would think they know something
about XML. Some of the authors consult also but they do not know the
fundamentals, it makes me wonder about the quality of their consulting.


--tc



 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      12-04-2007
In article <zT25j.193237$(E-Mail Removed)> ,
geoff <(E-Mail Removed)> wrote:

>The snippet below had 'po' in front of 'billTo', 'shipTo', 'order', etc. but
>they say by moving the 'po' namespace definition to the 'poo' element, the
>child elements fall into that namespace:


That's not true, in particular this statement:

... the content of any namespace-prefixed element is considered to
belong to the namespace of its parent element ...

But there's something like it that is true. Namespaces are a notation
used to determine the interpretation of elements and attributes. The
responsibility for doing that determination rests with the application
that's processing the file. The obvious approach is to say that the
application interprets elements in some particular namespace (or group
of namespaces) as belonging to it, and treats others as uninterpreted
data. But some applications treat no-namespace children of their
elements as also belonging to the application, even though they're not
in its namespace.

Presumably the applications that understand the "po" namespace in this
example use the second approach.

XML Schemas provides support for this way of doing things through the
elementFormDefault attribute. If this is set to "unqualified" then
the schema can validate (by local element declarations) no-namespace
children of elements in the target namespace.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      12-04-2007
geoff wrote:
> The snippet below had 'po' in front of 'billTo', 'shipTo', 'order', etc. but
> they say by moving the 'po' namespace definition to the 'poo' element, the
> child elements fall into that namespace:


If so, they're wrong. However, you could get that effect by using the
Default Namespace Declaration:

<po id="43871" submitted="2001-10-05"
xmlns="http://www.skatestown.com/ns/po">
<billTo id="addr-1">
...
</billTo>
<shipTo href="addr-1"/>
<order>
...
</order>
</po>

Note that the Default Namespace Declaration only affects elements. If
you want attributes to be in a namespace, they have to use a properly
declared prefix. (However, it is not uncommon for namespaced nodes to
expect non-namespaced attributes, so always check your particular schema
or application spec to see whether this is going to be an issue.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      12-04-2007
To me, this looks like an error introduced in editing -- the authors
probably intended to introduce the Default Namespace Declaration syntax,
but somewhere in the technical editing process someone less knowledgable
made the erroneous guess that this was an error and "corrected" it.

(Having been a technical reviewer, I can see how that would happen.
Though in the case I was looking at, what the book really needed was an
expert co-author; the guy who was writing it wasn't as familiar with the
material as he should have been and the fact that English wasn't his
first language didn't help.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR CS0234: The type or namespace name 'DataAccessHelper' does not exist in the namespace 'BCC' (are you missing an assembly reference?) li.eddie@gmail.com ASP .Net 0 01-06-2006 11:31 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Reaching into the default namespace when using another namespace. Jason Heyes C++ 1 11-19-2004 02:36 AM
Namespace: Is it a scope or a namespace? Anonymous C++ 3 08-18-2003 01:31 PM
Help:Why can't I use namespace System.Web? It is said that this namespace doesn't exist. But it should exist. ASP .Net 1 07-29-2003 04:31 PM



Advertisments