- From: Frank VAN LINGEN <Frank.van.Lingen@cern.ch>
- Date: Mon, 24 Sep 2001 10:02:26 -0400 (EDT)
- To: xmlschema-dev@w3.org
Hi, I am trying to use namespaces within xmlschema. The idea is that editors of instances of this schema do not have to use prefixes for namespaces, since these are already described in the schema. However, if I try to do this, it turns out that I stil have to use prefixes for namespaces in my instance document. Below is a small example (part of schema and instance document). In the schema I import a schema related to a namespace. Within the type definition of materialfraction I use this namespace to indicate that it should use a structure defined in the schema associated with this namespace. I thought this would give enough information not to use namespaces in the instance document. However, I still have to declare a namespace for this element (see instance part). Is there a way to use namespaces in schemas and avoid them in instance documents? -----snippet of an xml schema I use: <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.cern.ch/DDLMaterial" xmlns="http://www.cern.ch/DDLMaterial" xmlns:DDLReference="http://www.cern.ch/DDLReference" elementFormDefault="unqualified"> <!-- Importing --> <xsd:import namespace="http://www.cern.ch/DDLReference" schemaLocation="DDLReference.xsd" /> <!-- Element definitions --> <xsd:element name="MaterialFraction" type="MaterialFractionType"/> <!-- Type definitions --> <xsd:complexType name="MaterialFractionType"> <xsd:sequence> <xsd:element ref="DDLReference:rMaterial" minOccurs='1' maxOccurs='1'/> </xsd:sequence> <xsd:attributeGroup ref="MaterialFractionAttributes"/> </xsd:complexType> <!-- Attribute definitions --> <xsd:attributeGroup name="MaterialFractionAttributes"> <xsd:attribute name="fraction" type="xsd:float" use="required"/> </xsd:attributeGroup> </xsd:schema> ----------------------snippet of instance document based on this schema <?xml version="1.0"?> <CompositeMaterial xmlns="http://www.cern.ch/DDLMaterial" xmlns:DDLReference="http://www.cern.ch/DDLReference" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.cern.ch/DDLMaterial DDLMaterial.xsd http://www.cern.ch/DDLReference DDLReference.xsd" name="testmat" ID="12" symbol="te" method="mixture by weight"> <Density value="1.2" units="g/cm^3"/> <MaterialFraction fraction="0.4"> <DDLReference:rMaterial name="testref" url="http://www.cern.ch/somewhere.xml"/> </MaterialFraction> <MaterialFraction fraction="0.3"> <DDLReference:rMaterial name="testref1" url="http://www.cern.ch/somewhere.xml"/> </MaterialFraction> </CompositeMaterial> ---------------------------------- Frank van Lingen
Received on Monday, 24 September 2001 11:28:05 UTC