Re: Implementing xs:include for a schema without targetNamespace

I'm not 100% sure I understand your question, but consider the following:

schemadoc1.xsd:

<xsd:schema targetNamespace="ns1Uri">
   <xsd:include schemaLocation="schemadoc2.xsd"/>
</xsd:schema>

schemadoc2.xsd:

<!-- no targetNamespace on this one -->
<xsd:schema xmlns:ns1="ns1Uri">
   <xsd:include schemaLocation="schemadoc2.xsd"/>

  <!-- this winds up defining {ns1Uri, someelement} -->
  <!-- the type referenced is still xsd:integer -->
  <xsd:element name="someelement" type="xsd:integer">
    <xsd:annotation>
      <xsd:documentation xmlns:html="http://www.w3.org/1999/xhtml">
         <!-- the following still uses {http://www.w3.org/1999/xhtml,p} 
-->
         <html:p>here is a paragraph</html:p>
      <xsd:documentation>
    </xsd:annotation>
  </xsd:element>
</xsd:schema>

The pertinent clause of the schema recommendation states [1] regarding 
include of a schema document with no targetNamespace:

"anywhere the ·absent· target namespace name would have appeared, the 
·actual value· of the targetNamespace [attribute] of SII' is used. In 
particular, it replaces ·absent· in the following places:

* The {target namespace} of named schema components, both at the top level 
and (in the case of nested type definitions and nested attribute and 
element declarations whose code was qualified) nested within definitions;
* The {namespace constraint} of a wildcard, whether negated or not;"

I think that's pretty clear.  In the case of documentation, for example, 
you are using namespaces but NOT the targetnamespace.   Same is true in 
type type= reference.  In general it is NOT references or uses of elements 
from other namespaces that get affected, it's the names of things that are 
defined (and wildcards.)

If you are building a schema processor, it is absolutely essential that 
you read the recommendation and understand it in detail.  It is not, 
unfortuantely, a specification that is easy to grasp the first few minutes 
you read it.  You will find, though, that it takes great care to spell out 
the details of the language with some care, and that's exactly what you 
need as an implementor of a processor.  In general, you want to learn what 
the schema components (type definitions, etc.) are and what the 
constraints on them are.  Layered on that, you can find out how the 
components are built up from the information provided in schema documents; 
 for example, you'll find out that some of the properties of a type 
definition may be inherited from the base type, and that base type may be 
declared in a different schema document.   I hope this answers your 
question about include.  Good luck!



[1] http://www.w3.org/TR/2004/PER-xmlschema-1-20040318/#compound-schema





--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------






        Jochen Wiedmann <jochen.wiedmann@freenet.de>
        Sent by: xmlschema-dev-request@w3.org
        08/21/2004 03:47 PM
 
                 To: xmlschema-dev@w3.org
                 cc: (bcc: Noah Mendelsohn/Cambridge/IBM)
                 Subject: Implementing xs:include for a schema without 
targetNamespace



Hi,

if I have an XML schema with target namespace, that includes another 
instance of XML schema without target namespace, then the SPEC requires,
that the included schema be converted to a schema with the target
namespace of the including schema. My problem is, how to implement
this in a schema processor.

The basic approach would of course be, to load the schema, convert all 
references to the target namespace, and be done. However, IMO this is
not sufficient, because the schema might contain additional references.
For example, consider a language extending XML schema by using the
xs:appinfo elements, like JAXB (http://java.sun.com/xml/jaxb/) does:
It is quite possible, that attributes below xs:appinfo contains other
references, that my schema processor doesn't know about. My 
understanding is, that these should be converted too.

Thus, I have a different idea, which I would like to discuss: The
schema processor is iun fact a SAX parser. As such, it receives SAX 
events, in particular

     public void startElement(String pURI, String pLocalName,
                              String pQName, Attributes pAttrs);
     public void endElement(String pURI, String pLocalName,
                            String pQName);
     public void startPrefixMapping(String pPrefix, String pURI);

The idea is, to map all URI's in the above SAX events from the ""
(the absent namespace in SAX) to the desired target namespace.

Thoughts?


Regards,

Jochen


-- 
http://lilypie.com/baby1/050423/1/5/1/+1

Received on Monday, 23 August 2004 13:32:58 UTC