Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Hiding namespace prefixes in the instance document

From: George Cristian Bina <george@---------.--->
To: Antti Sissonen <antti_sissonen@-------.--->
Date: 1/4/2006 1:57:00 PM
Hi Antti,

It seems a bug in how the generated document is created, for instance 
oXygen creates the following document if you give it the 
Importer_Schema.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<ImporterSchema xmlns="importer:schema:namespace"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="importer:schema:namespace Importer_Schema.xsd">
   <ImportedComplexType>
     <ImportedElement xmlns=""></ImportedElement>
   </ImportedComplexType>
</ImporterSchema>

As you can see the ImportedElement is correctly placed in no namespace 
by resetting the default namespace using xmlns="".

I think in general you should clarify what namespaces you want for your 
elements and then create the schema for them. There are a couple of 
things you should have clear in mind when you define elements. You can 
have in a schema global elements and local elements. The global elements 
belong to the schema target namespace. The local elements belong either 
to no namespace or to the schema target namespace depending on the 
element/@form attribute or if that is not present depending on the 
schema/@elementFormDefault attribute. If none of these are present the 
local elements belong to no namespace as the elementFormDefault 
attribute default value is unqualified.

In your case the ImportedElement is a local element and you have 
schema/@elementFormDefault="unqualified" so the ImportedElement is 
defined in no namespace.

Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com


Antti Sissonen wrote:
> 
> Hi.
> 
> I have a schema that imports another one. I=92m trying to keep the 
> namespace prefixes hidden in the xml instance and at the same time have=
 
> namespaces defined for both schemas. I assume that this is not possible=
 
> if both schemas have their own targetNamespaces.
> One way to do this would be the chameleon design, ie. use include 
> instead of import and have no namespace definition in the imported 
> schema. What are the downsides of this? Is the modularity somehow more 
> restricted?
> Is there possibly some other options that I'm not recognising?
> 
> 
> Enclosing schema:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> xmlns="importer:schema:namespace" 
> xmlns:imported="imported:schema:namespace" 
> targetNamespace="importer:schema:namespace" elementFormDefault 
> ="qualified" attributeFormDefault="unqualified">
> <xs:import namespace="imported:schema:namespace" 
> schemaLocation="Imported_Schema.xsd"/>
> <xs:element name="ImporterSchema" type="ImporterType"/>
> 
>     <xs:complexType name="ImporterType">
>         <xs:sequence>
>             <xs:element name="ImportedComplexType" 
> type="imported:ImportedType" minOccurs="0"/>
>         </xs:sequence>
>     </xs:complexType>
> </xs:schema>
> 
> Imported (common component) schema:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> xmlns:imported="imported:schema:namespace" 
> targetNamespace="imported:schema:namespace" 
> elementFormDefault="unqualified" attributeFormDefault="unqualified"=
>
>     <xs:complexType name="ImportedType">
>         <xs:sequence>
>             <xs:element name="ImportedElement" type="xs:string" 
> minOccurs="0"/>
>         </xs:sequence>
>     </xs:complexType>
> </xs:schema>
> 
> Generated instance document (not valid though, why?):
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!--Sample XML file generated by XMLSpy v2005 rel. 3 U 
> (http://www.altova.com)-->
> <ImporterSchema
> xmlns="importer:schema:namespace"
> xmlns:imported="imported:schema:namespace"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:schemaLocation="importer:schema:namespace Importer_Schema.xsd">
> 
>     <ImportedComplexType>
>         <ImportedElement>String</ImportedElement>
>     </ImportedComplexType>
> </ImporterSchema>
> 
> 
> 
> _________________________________________
> 
> Antti Sissonen [Antti_Sissonen@h...]
> 
> 
> 
> 

From mike@s... Wed Jan 04 09:59:14 2006
Received: from lisa.w3.org ([128.30.52.41])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1Eu5QI-0007wV-


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent