W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2008

Re: suitable data type to store patterns..

From: Pete Cordell <petexmldev@tech-know-ware.com>
Date: Wed, 9 Jan 2008 21:56:29 -0000
Message-ID: <000901c8530a$8fed4890$a100a8c0@Codalogic>
To: "dave" <ceek63@yahoo.com>, <xmlschema-dev@w3.org>

----- Original Message From: "dave" ----- 
> Am using W3C XML Schema.
> I need to store some pattern values such as
> "[/<*ab^&[[1"  (excluding quotes) in XML. What would
> be the data type for an element which would store such
> values as is?

There's no XSD schema type that allows you to store things like < and & in 
an XML instance in their raw form.  For example, the following would be an 
illegal document:


All you can do is define your type as xs:string (or some restriction 
thereof) and the XML tool or library that you use to interface to your XML 
instance should hopefully do the conversion for you from something like: <& 
to &lt;&amp; and vice versa.

Alternatively your tool (or you if you're rolling your own) may choose to 
store the data in what's called a CDATA Section [1].  This wraps text 
between the tokens <![CDATA[ and ]]>, for example:


Obviously if your data includes the sequence ]]>, you have to be careful to 
do something like:


for &]]>& (see [2]).

These escaping methods are issues of XML instance well-formedness however, 
which is something a schema can not have no direct impact on.


Pete Cordell
Visit http://www.codalogic.com/lmx/ for XML C++ data binding

[1] http://www.w3.org/TR/2006/REC-xml-20060816/#sec-cdata-sect
[2] http://www.w3.org/TR/2006/REC-xml-20060816/#syntax 
Received on Wednesday, 9 January 2008 21:57:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:45 UTC