XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] XML schema - multiple import of module

Hi Mark,

Making your document well-formed

<doc>
   <div>
     <title>Section 1</title>
     <p>Some text...</p>
     <p>
       <law:extract xmlns:law="http://www.example.com/law";>
         <title>Title of Regulation</title>
         <p>Text of regulation</p>
       </law:extract>
     </p>
   </div>
</doc>

and giving it to Trang to convert it to XML Schema I get two valid 
schemas that validate the instance document, you can see them below. You 
may start from them and add more elements, or you may want to provide 
Trang with more sample XML files to cover more of your desired structure.

test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
elementFormDefault="qualified"
   xmlns:law="http://www.example.com/law";>
   <xs:import namespace="http://www.example.com/law"; 
schemaLocation="law.xsd"/>
   <xs:element name="doc">
     <xs:complexType>
       <xs:sequence>
         <xs:element ref="div"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
   <xs:element name="div">
     <xs:complexType>
       <xs:sequence>
         <xs:element ref="title"/>
         <xs:element maxOccurs="unbounded" ref="p"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
   <xs:element name="title" type="xs:string"/>
   <xs:element name="p">
     <xs:complexType mixed="true">
       <xs:sequence>
         <xs:element minOccurs="0" maxOccurs="unbounded" ref="law:extract"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
</xs:schema>

law.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
elementFormDefault="qualified"
   targetNamespace="http://www.example.com/law"; 
xmlns:law="http://www.example.com/law";>
   <xs:import schemaLocation="test.xsd"/>
   <xs:element name="extract">
     <xs:complexType>
       <xs:sequence>
         <xs:element ref="title"/>
         <xs:element ref="p"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
</xs:schema>

Note that I used http://www.example.com/law as namespace for your 
law:extract element - you may change that with whatever you actually use.

As Lech Rzedzicki suggested, NVDL is a technology that allows you to 
easily deal with mixing different languages without the need to change 
the schemas for those languages. For instance assuming you have test.xsd 
defining only the content from no namepsce and law.xsd defining the 
content in the http://www.example.com/law namespace then you can use an 
NVDL script like the one below to validate all the content in no 
namespace against the test.xsd schema and all the content from 
http://www.example.com/law against the law.xsd schema:

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0";>
   <namespace ns="">
     <validate schema="test.xsd">
       <mode>
         <namespace ns="http://www.example.com/law";>
           <validate schema="law.xsd">
             <mode>
               <namespace 
ns="http://www.example.com/law";><attach/></namespace>
               <anyNamespace><unwrap/></anyNamespace>
             </mode>
           </validate>
           <unwrap>
             <mode>
               <namespace ns=""><attach/></namespace>
               <anyNamespace><unwrap/></anyNamespace>
             </mode>
           </unwrap>
         </namespace>
       </mode>
     </validate>
   </namespace>
</rules>

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

DUNN, Mark wrote:
> Hello,
> 
> I'm new to XML Schemas, and investigating conversion of a DTD to an XML
> Schema. I have a problem describing the Schema version of the following
> structure:
> 
> <doc>
>  <div>
>   <title>Section 1</title>
>   <p>Some text...</p>
>   <p>
>    <law:extraxt>
>     <title>Title of Regulation</title>
>     <p>Text of regulation</p>
>    </law:extract>
>   </p>
>  </div>
> </doc>
> 
> 
> The problem is in the non-namespaced <title> and <p> elements occurring
> within the namespaced <law:extract> element. They are the same as the
> ones occurring outside this element, so I'd like to define them only
> once.
> 
> My attempt at expressing this structure uses three .xsd files:
> 
> main.xsd:
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> xmlns="http://xsd.oup.com/ac-xsd/";
> xmlns:law="http://xsd.oup.com/ac-law/";
> targetNamespace="http://xsd.oup.com/ac-xsd/";
> elementFormDefault="qualified">
> 	<xs:redefine schemaLocation="struct.xsd">
> 		<xs:group name="paragraph-content">
> 			<xs:choice>
> 				<xs:group ref="paragraph-content"/>
> 				<xs:element ref="law:extract"/>
> 			</xs:choice>
> 		</xs:group>
> 	</xs:redefine>
> 	<xs:import namespace="http://xsd.oup.com/ac-law/";
> schemaLocation="law.xsd"></xs:import>
> 	...
> </xs:schema>
> 
> law.xsd:
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> elementFormDefault="qualified"
> targetNamespace="http://xsd.oup.com/ac-law/";
> xmlns:law="http://xsd.oup.com/ac-law/";
> xmlns:struct="http://xsd.oup.com/ac-xsd/";>
> 	<xs:import schemaLocation="struct.xsd"
> namespace="http://xsd.oup.com/ac-xsd/";></xs:import>
> 	<xs:element name="extract">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="struct:title"
> minOccurs="0"/>
> 				<xs:element ref="struct:p"
> minOccurs="1"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> 	...
> </xs:schema> 
> 
> 
> struct.xsd:
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> elementFormDefault="qualified" attributeFormDefault="unqualified"
> targetNamespace="http://xsd.oup.com/ac-xsd/";
> xmlns="http://xsd.oup.com/ac-xsd/";>
> 	<xs:group name="general-inline">
> 		<xs:choice>
> 			<xs:element ref="b"/>
> 			<xs:element ref="i"/>
> 		</xs:choice>
> 	</xs:group>
> 	<xs:group name="paragraph-content">
> 		<xs:choice>
> 			<xs:group ref="general-inline"></xs:group>
> 			<!-- ... [plus others] ... --->
> 		</xs:choice>
> 	</xs:group>
> 	<xs:element name="p">
> 		<xs:complexType mixed="true">
> 			<xs:choice minOccurs="0" maxOccurs="unbounded">
> 				<xs:group ref="paragraph-content"/>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
> 	...
> </xs:schema>
> 
> 
> When I try saving the schema files in XMLSpy 2009, I get an error saying
> that <title> is already declared, presumably because the file struct.xsd
> has ben imported twice.
> 
> The W3C spec says that importing twice is legitimate, but vendors are
> encouraged to raise it as an error. Fair enough - I don't like the
> circularity in my description.
> 
> But the structure itself seems reasonable, I just can't see a way of
> expressing it in XML Schema.
> 
> Can anyone help?
> 
> 
> Kind regards,
> 
> Mark Dunn
> XML Data Engineer
> Oxford University Press
> 
> Oxford University Press (UK) Disclaimer
> 
> This message is confidential. You should not copy it or disclose its contents to anyone. You may use and apply the information for the intended purpose only. OUP does not accept legal responsibility for the contents of this message. Any views or opinions presented are those of the author only and not of OUP. If this email has come to you in error, please delete it, along with any attachments. Please note that OUP may intercept incoming and outgoing email communications.
> 
> _______________________________________________________________________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> 


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS