SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Originally posted by Pedro Erencia:
I'd say it's {http://www.Monson-Haefel.com/jwsbook/ADDR}, since it overrides default namespace.
4.1.13 SOAP Body and Namespaces
The use of unqualified element names may cause naming conflicts, therefore qualified names must be used for the children of soap:Body.
R1014 The children of the soap:Body element in a MESSAGE MUST be namespace qualified.
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
CASE III has two possible answers:
* The child elements are in the {http://www.Monson-Haefel.com/jwsbook/ADDR} namespace IF the relevant schema doesn't specify elementFormDefault="qualified" - as the child elements inherit the namespace from the parent.
* The child elements are in the {http://www.Monson-Haefel.com/jwsbook/PO} namespace IF the relevant schema specifies elementFormDefault="qualified" - as the lack of a prefix clearly indicates that the elements belong to the default namespace.
This can get pretty confusing. That is why the WS-I Basic Profile forces you to always use elementFormDefault="qualified" for XML inside the SOAP body. It puts an end to child elements being automatically in the parent's namespace...
4.1.13 SOAP Body and Namespaces
The use of unqualified element names may cause naming conflicts, therefore qualified names must be used for the children of soap:Body.
Originally posted by Pedro Erencia:
It only says that we can't do something like this
In that case the element "city" could be associated with a namespace other than "http://uri"
Without BP and its assumption of local qualified names you revert back to "unqualified" which is the default for plain XML. As now local unqualified names can and will be used "city" is subject to a naming collision (if both schemas contain a "city" element) because we cannot tell whether its qualified name is {http://uri}city or {http://otheruri}city.
In the first item of CASE III I arbitrarily chose to break the tie by proximity. In fact in plain XML which permits local unqualified names name, street, city, state, and zip [BOLD]could simply be local unqualified names OR belong to the default namespace - there is no way tell. [/BOLD]
At this point you have to check whether these elements actually exist in the respective namespaces - and if they exist in both namespaces then you are dealing with a naming collision. Once you require local qualified names your problems go away.
Originally posted by Pedro Erencia:
how it can be local unqualified OR belong to the default namespace ?
When i talk about a qualify name i'm referring to a name which has been assigned a namespace
Could you please put an example of a name-collision that explains the statement i've quoted ?
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Definition: A qualified name is a name subject to namespace interpretation.
Definition: An expanded name is a pair consisting of a namespace name and a local name.
Definition: For a name N in a namespace identified by a URI I, the namespace name is I. For a name N that is not in a namespace, the namespace name has no value.
Definition: In either case the local name is N.
The unprefixed "street" tag-name is clearly assumed to be {http://www.example.com/PO1}street, not {NO NAMESPACE}street because "unqualified locals" are permitted and it is classified as such.
The child elements (<id>, <thedate>, and <avalue>) are defined as local
elements (defined inside a complex type), and therefore must be unqualified.
Therefore the elements must include the "no default" namespace definitions
(xmlns=""). If you prefer to make these element qualified, you can add the
elementFormDefault="qualified" attribute to the <schema> definition. But
this issue really shouldn't make a difference.
Anne Thomas Manes
Originally posted by Pedro Erencia:
because street is out of any namespace scope.
Originally posted by Pedro Erencia:
If the schema determines that it must be unqualifed then the instance is invalid because the zip should be associated with no namespace.
because the local elements belong to the parent's namespace
An unqualified setting means that only the globally declared elements must be explicitly qualified, and the locally declared elements must not be qualified.
Just because your compiler compiles your code doesn't imply that either your code is syntactically correct or that the output of the compiler is semantically correct with respect to the langauge specification.
The namespace URI of this node, or null if it is unspecified. This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
In contrast, when we choose unqualified, we are specifying that only the globally declared elements and attributes in the instance must have a namespace
In contrast, when we choose unqualified, we are specifying that only the globally declared elements and attributes in the instance must have a prefix
Furthermore, elementFormDefault[="unqualified"] and attributeFormDefault[="unqualified"] require that the prefix is not applied to any of the locally declared elements such as shipTo, billTo, name and street, and it is not applied to any of the attributes (which were all declared locally).
Apparently you haven't come across the following:
quote:
Just because your compiler compiles your code doesn't mean that your code is syntactically correct with respect to the language specification, nor does it imply that the
output of the compiler is semantically correct with respect to the langauge specification.
So the output of that program doesn't prove anything.
Furthermore:
org.w3c.dom.Node.getNamespaceURI()
quote:The namespace URI of this node, or null if it is unspecified. This is not a computed value that is the result of a namespace lookup based on an examination of the
namespace declarations in scope. It is merely the namespace URI given at creation time.
Furthermore, elementFormDefault[="unqualified"] and attributeFormDefault[="unqualified"] require that the prefix is not applied to any of the locally declared elements such as
shipTo, billTo, name and street, and it is not applied to any of the attributes (which were all declared locally).
Throw a "apo:" in front of the "street" in your sample XML. In my DOM version I get the following
code:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'apo:street'. One of '{street}' is expected.
So basically it is telling me that I'm not allowed to used a prefix.
Not that error messages have ever been that correct or informative.
Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
2. Explicitly declared one xmlns:addr="http://www.Monson-Haefel.com/jwsbook" because child inherits from the parent.
If there is a default namespace declaration in scope, the expanded name corresponding to an unprefixed element name has the URI of the default namespace as its namespace name. If there is no default namespace declaration in scope, the namespace name has no value. The namespace name for an unprefixed attribute name always has no value. In all cases, the local name is local part (which is of course the same as the unprefixed name itself).
Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Originally posted by Pedro Erencia:
That code validates the instance against an schema
And that schema says that the shipTo element is expected to not belong to any namespace.
No prefixs were present in name or street. They were qualified without prefix, and the code detects it.
That quote says nothing about namespaces.
Where did you find the statements that made you think that shipTo is expected to be in the {http://www.example.com/PO1} in a valid instance?
Originally posted by Pedro Erencia:
Qualify it without a prefix
...
It will insist in the same error.
Originally posted by Naren Chivukula:
If the supporting schema(not declared for simplicity) for the above XML says elementFormDefault="unqualified", then the above XML instance is INCORRECT because
Originally posted by Peer: So far the evidence suggests that you are not allowed to have an active default namespace within an element with "unqualified locals" - period. The default namespace must be canceled by the global element that contains "unqualified locals". Therefore a default namespace cannot exist within the confines of a global element that has "unqualified locals".
Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Namespace analysis would be too complex and slow
This is where I disagree. By virtue of the schema "targetNamespace" declaration shipTo should be part of {http://www.example.com/PO1}.
If form is present and its �actual value� is qualified, or if form is absent and the �actual value� of elementFormDefault on the <schema> ancestor is qualified, then the �actual value� of the targetNamespace [attribute] of the parent <schema> element information item, or �absent� if there is none, otherwise �absent�.
4.1.13 SOAP Body and Namespaces
The use of unqualified element names may cause naming conflicts, therefore qualified names must be used for the children of soap:Body.
R1014 The children of the soap:Body element in a MESSAGE MUST be namespace qualified.
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|