Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Wildcards in SML schema

From: usenet@--------------.---
To: NULL
Date: 6/6/2007 1:48:00 AM

On 6 Jun, 04:46, Grant Robertson <b...@bogus.invalid> wrote:
> If I use the 'any' element in my schema to allow elements from another
> schema to be used in instance documents based on my schema, is there a
> way to force that the contents of that element must be an entire,
> complete instance document for that other schema?
>
> Let's say I have the following schema:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>     <xs:element name="BogusElement" type="BogusType"/>
>     <xs:complexType name="BogusType">
>         <xs:sequence>
>             <xs:any namespace="http://www.w3.org/1999/xhtml"/>
>         </xs:sequence>
>     </xs:complexType>
> </xs:schema>

This would allow any global element from www.w3.org/1999/xhtml/.

> <?xml version="1.0" encoding="UTF-8"?>
> <BogusElement
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:noNamespaceSchemaLocation="Untitled1.xsd"
>   xmlns:xhtml="http://www.w3.org/1999/xhtml">
>    <xhtml:strong>Bolded Text.</xhtml:strong>
> </BogusElement>
>
> be a valid document under the above schema?

Yes.

> How can I make it so that the contents of the BogusElement element in the
> instance document must be a complete XHTML document in order to be valid?
> Or would I just have to make that a verbal rule, not expressed in the
> schema?

You could try the following schema approach...

 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="BogusElement" type="BogusType"/>
     <xs:complexType name="BogusType">
         <xs:sequence>
             <xs:element xmlns:xhtml="http://www.w3.org/1999/xhtml"
ref="xhtml:xthml"/>
         </xs:sequence>
     </xs:complexType>
 </xs:schema>

> To complicate things further: Let's say I wanted that element to contain
> only one of a list of valid, complete documents such as either a complete
> html document OR a complete XHTML document OR a complete DocBook
> document, all with headers. How would I do that?

Including an HTML document obviously has the problem that an HTML
document is not typically well-formed XML.  But we can leave that
aside for the moment!

Also, I'm not sure of the valid set of DocBook schemas.

Given that, your schema could look something like:

 <?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="BogusElement" type="BogusType"/>
     <xs:complexType name="BogusType">
         <xs:choice>    <!--Changed from sequence-->
             <xs:element xmlns:xhtml="http://www.w3.org/1999/xhtml"
ref="xhtml:xthml"/>
             <xs:element xmlns:docbook="http://docbook"
ref="docbook:docbook"/>
         </xs:choice>
     </xs:complexType>
 </xs:schema>

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
 http://www.codalogic.com/lmx/
=============================================



transparent
Print
Mail
Like It
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