[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Hiding namespace prefixes in the instance document

From: Antti Sissonen <antti_sissonen@hotmail.com>
Date: Wed, 04 Jan 2006 11:18:07 +0200
Message-ID: <BAY109-F17213E20D449208B4675DE62F0@phx.gbl>
To: xmlschema-dev@w3.org
hotmail.com importer

Hi.

I have a schema that imports another one. I?m 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@hotmail.com]
Received on Wednesday, 4 January 2006 09:28:43 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.