import - XML Schema: how to reference a type from a no namespace XSD -


so have xsd has no namespace specified.

i import schema (b.xsd) has namespace specified "targetnamespace='my-name-space'"

<import schemalocation="a.xsd"/> 

after want create element in b.xsd

<element name="authenticationrequest" type="authenticationrequest"/> 

this fails validation saying type authenticationrequest no found. type defined in a.xsd.

how reference type a.xsd in b.xsd??

the idea type attribute qname, meaning sensitive prefix bindings.

if imported schema has no namespace, seems case here, value of type attribute should unprefixed. however, since in schema snippet seems default namespace defined , identical xml schema namespace (http://www.w3.org/2001/xmlschema), engine attempts looking type called authenticationrequest in xml schema namespace. can solved binding xml schema namespace prefix, xs or xsd, rather making default.

<xs:schema   xmlns:xs="http://www.w3.org/2001/xmlschema"   ... >     <xs:import schemalocation="a.xsd"/>     <xs:element name="authenticationrequest" type="authenticationrequest"/> </xs:schema> 

for completeness: if imported schema has target namespace, 2 things need done:

  1. binding target namespace of imported schema prefix, say, imported
  2. prefixing value of type attribute prefix, so:

    <xs:schema   xmlns:xs="http://www.w3.org/2001/xmlschema"   xmlns:imported="http://www.example.com/imported"   ... >   <xs:import schemalocation="a.xsd" namespace="http://www.example.com/imported"/>   <xs:element name="authenticationrequest" type="imported:authenticationrequest"/> </xs:schema> 

as mentioned in link posted on chameleon design, alternative importing schema including schema.

however, design, value of type attribute still needs defined properly, is:

  • either no prefix (and no default namespace) if there no target namespace
  • or appropriate prefix, bound target namespace
  • or no prefix, target namespace being defined default namespace

very importantly, above applies if there 1 schema, no other schemas imported or included. works out of box if schema has no namespace, needs considered if there target namespace.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -