473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Wildcards in SML schema

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>

It has only the one element BogusElement and it can contain only the one
child element from the XHTML schema. Does this force the BogusElement
element in the instance document to contain a complete XHTML document
including headers or would

<?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?

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?

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?

Basically, I am trying to build a standard that acts as an envelope
around complete documents which can be of various different text-based
formats.
Jun 6 '07 #1
6 2210
On 6 Jun, 04:46, Grant Robertson <b...@bogus.invalidwrote:
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/
=============================================

Jun 6 '07 #2
Hi Grant,

Grant Robertson <bo***@bogus.invalidwrites:
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?
If the schema for the namespace that you allow in your wildcard only
defines one global element that represents a complete document of
that vocabulary, then yes.

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>

It has only the one element BogusElement and it can contain only the one
child element from the XHTML schema. Does this force the BogusElement
element in the instance document to contain a complete XHTML document
including headers or would

<?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?
It depends on the schema that defines the XHTML vocabulary. If it defines
strong as a global element then the above instance will be valid.
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?
I think if you have a predefined set of "content documents" then using
the choice construct might be a good idea. Alternatively, you can
introduce another level of indirection. With this approach you change
BogusType to read like so:

<xs:complexType name="BogusType">
<xs:sequence>
<xs:any namespace="http://www.example.com/envelop-content"/>
</xs:sequence>
</xs:complexType>

In other words, you only allow elements in place of a wildcard to be
from a namespace (or namespaces) that you control. Then you define
the envelop-content vocabulary like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
targetNamespace="http://www.example.com/envelop-content">

<xs:import ... import XHTML schema ...>

<xs:element name="xhtml-content">
<xs:complexType>
<xs:sequence>
<xs:element ref="xhtml::html"/>
</xs:sequence>
</xs:complexType>
</xs:element>

... Other *-content elements

</xs:schema>
hth,
-boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Jun 6 '07 #3
In article <11*********************@w5g2000hsg.googlegroups.c om>,
us****@tech-know-ware.com says...
<xs:element xmlns:xhtml="http://www.w3.org/1999/xhtml" ref="xhtml:xthml"/>

It looks like what you have done here is replace the

<xs:any namespace="http://www.w3.org/1999/xhtml"/>

component of my schema with an element-type component that lists a
namespace and then references the root element of that namespace. Is my
interpretation of this correct? Secondly, is this a valid XSD component?
What is this technique called (so I can look it up)?
Jun 7 '07 #4
Perhaps I should ask the more general question:

When people are creating an XML schema and they want to allow content
creators to insert full XML documents based on other schemas directly
within only certain elements of XML documents based on their new schema:
what do they do?
Jun 7 '07 #5
Grant Robertson wrote:
When people are creating an XML schema and they want to allow content
creators to insert full XML documents based on other schemas directly
within only certain elements of XML documents based on their new schema:
what do they do?
If you don't know which other schemas, make the content model of those
specific elements accept elements from other schemas (by using xsd:any).
I don't know of any way to say "accept only top-level elements/complete
documents"; once you open the window, anything can fly in.

Or you can spell out the specific root nodes you're willing to accept as
part of this element's content.

For an example of this, look at how the W3C has been designing XHTML to
allow plugging in fragments written in other specifications.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Jun 7 '07 #6
On 7 Jun, 16:21, Grant Robertson <b...@bogus.invalidwrote:
In article <1181119691.583946.53...@w5g2000hsg.googlegroups.c om>,
use...@tech-know-ware.com says...
<xs:element xmlns:xhtml="http://www.w3.org/1999/xhtml" ref="xhtml:xthml"/>

It looks like what you have done here is replace the

<xs:any namespace="http://www.w3.org/1999/xhtml"/>

component of my schema with an element-type component that lists a
namespace and then references the root element of that namespace. Is my
interpretation of this correct? Secondly, is this a valid XSD component?
What is this technique called (so I can look it up)?
That's right. Basically, it's a regular <xs:element ref=".../schema
statement. The specification of the xhtml namespace prefix is
included in the element definition as it seems a convenient place to
do it, but it could equally have been defined in any of the parent
elements.

(Incidently - the current draft version of XSD 1.1 has better control
of xs:any wildcards. I wouldn't wait until the standard is published
and tools are available though!)

HTH,

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

Jun 7 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bharath Dhurjati | last post by:
Hello, I am looking for documentation that specifies the following behavior exhibited by java. The following (assuming MyClass.class is accessible and has a main()) java MyClass * yields...
1
by: Ralph Noble | last post by:
I thought this problem would go away over the Christmas holiday, but of course it did not. I'm trying to write a stored procedure incorporating wildcards, so I can search for variations. Example,...
3
by: sashi | last post by:
Hi, Is it possible to use wildards in SQL to drop a constraint on a table? Thanks!
11
by: Shyguy | last post by:
I need to import a text file pretty much daily. I download the file and change the name to a standard name and then run the code to import the file into a table in my database. The problem is...
10
by: Alvaro Puente | last post by:
Hi all! Do any of you know if wildcards are accepted when calling rename() function? Thanks/Alvaro
1
by: Anandan | last post by:
Hi, This is regarding Dataset Filter: WILDCARD CHARACTERS Both the * and % can be used interchangeably for wildcards in a LIKE comparison. If the string in a LIKE clause contains a * or %,...
19
by: Alan Carpenter | last post by:
Access 8 on Win98 and WinXP I'm having trouble with wildcards in the .Filename property of the FileSearch Object giving different results on win98 and XP. I've been successfully using...
3
by: vhrao | last post by:
I am trying to validate a xml file with two schema files cust.xsd and cust1.xsd. The schema file cust.xsd allows addition of elements from another schema cust1.xsd by using xs:any wildcard. ...
5
by: nidaar | last post by:
From a security point of view, is accepting wildcards like "%" in input parameters of stored procedures against any best practices? As an example, if a user defined function uses "Productname...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.