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

RE: Possible to use wildcards in schema element names?

  • From: "David Lee" <dlee@calldei.com>
  • To: "'Kevin Gibbs'" <kevin.kgibbs@gmail.com>, "'xml-dev'" <xml-dev@l...>
  • Date: Fri, 26 Nov 2010 17:30:39 -0500

RE:  Possible to use wildcards in schema element names?


>> My question then is, "Is it possible, in the schema, to use wildcards
?? or regex for the field elements?

By "field elements' I presume you mean the element names ?
No. Its not possible (Someone tell me I'm wrong !)
What you *can* do is use xquery or xslt to transform this "wild"document into something more "reasonable".
XSLT and XQuery could convert the document into something much more data/xml friendly like

   <person>
	<name>bill</name>
	<fields>
		<field>1</field>
		<field>2</field>
		...
	</fields>
  </person>
  ...





----------------------------------------
David A. Lee
dlee@calldei.com
http://www.xmlsh.org

-----Original Message-----
From: Kevin Gibbs [mailto:kevin.kgibbs@gmail.com] 
Sent: Friday, November 26, 2010 5:10 PM
To: xml-dev
Subject:  Possible to use wildcards in schema element names?


Hi all,
I'm trying to generate a schema for some xml (for which I have no
control over the format)
Consider the following xml example:
<?xml version="1.0" encoding="UTF-8"?>
<document>
   <name>Bill</name>
   <field1>abc</field1> <!-- any number of fields -->
   <field2>def</field2>
   <field3>ghi</field3>
   <field4>jkl</field4>

   <name>John</name>
   <field3>uvw</field3> <!-- need not start with field1 -->
   <field4>xyz</field4>
</document>

As you can see, each "name" element has a varying number of "field*" siblings.
So, I've come with the following attempt (the eagle-eyed among you,
may notice that I'm no expert):
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
 <xs:element name="document">
   <xs:complexType>
     <xs:sequence>
       <xs:choice maxOccurs="unbounded">
         <xs:element ref="name"/>
         <xs:element ref="field" maxOccurs="unbounded"/>
       </xs:choice>
     </xs:sequence>
   </xs:complexType>
 </xs:element>
 <xs:element name="name" type="xs:NCName"/>
 <xs:element name="field*" type="xs:NCName"/> <!-- How is it possible
to perform wildcard? -->
</xs:schema>

My question then is, "Is it possible, in the schema, to use wildcards
or regex for the field elements?

Many thanks in anticipation - Jimmy

_______________________________________________________________________

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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.