Thanks for everyone's detailed answers, this is very helpful!
-Sean
On 10/20/06, Stanimir Stamenkov <stanio@xxxxxxxxxxxxx> wrote:
/Sean McCauliff/:
> I have a schema file where I define two complex types and one of the
> complex types defines an element with the type of the other complex
> type. When I write an instance file the enclosed element is in an
> empty namespace instead of being defined in the name space of the type
> or of the enclosing element. See instance_a.xml and schema_a.xsd
> below.
[...]
> If I change the schema so that the bType is defined as an element
> instead. Then "b" is not in the http://eslug.net namespace.
Element "b" _is_ in the "http://eslug.net" namespace - all
top-level/global components have the 'targetNamespace' of the schema
they are defined in.
> schema_b.xsd
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://eslug.net"
> xmlns="http://eslug.net"
> >
> <xsd:element name="b">
> <xsd:complexType >
> <xsd:attribute name="anotherattr" type="xsd:string" use="required" />
> </xsd:complexType>
> </xsd:element>
[...]
> I would rather use schema a, but elements of "bType" only seem to show
> up in the empty namespace forcing me to use schema_b.
>
> Is this a bug or there some misunderstanding with how namespaces are
> assigned to compexTypes in xml schema?
You may take a look at "3 Advanced Concepts I: Namespaces, Schemas &
Qualification" <http://www.w3.org/TR/xmlschema-0/#NS>, "3.1 Target
Namespaces & Unqualified Locals", "3.2 Qualified Locals". So as far
as I understand you just need to set
|elementFormDefault="qualified"| on the <schema> element.
You may also see how the {target namespace} of an element
declaration (for example) is determined from its representation
<http://www.w3.org/TR/xmlschema-1/#element-element>:
> If the <element> element information item has <schema> as its
> parent, the corresponding schema component is as follows:
>
> {target namespace} The ·actual value· of the targetNamespace
> [attribute] of the parent <schema> element information item, or
> ·absent· if there is none.
> [...]
>
> otherwise if the <element> element information item has
> <complexType> or <group> as an ancestor and the ref [attribute] is
> absent...
>
> {target namespace} 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·.
--
Stanimir
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xxxxxxxxxxxxxxxxx
For additional commands, e-mail: j-users-help@xxxxxxxxxxxxxxxxx
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|