W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2005

Re: Schema to express fixed length fields within a tag.

From: George Cristian Bina <george@oxygenxml.com>
Date: Wed, 28 Sep 2005 09:53:23 +0300
Message-ID: <433A3DE3.2010304@oxygenxml.com>
To: kurt steele <kurtsteele@yahoo.com>
Cc: xmlschema-dev@w3.org

Hi Kurt,

You can define a type as a list of 5 decimal numbers like in the sample 
below.

test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="test" type="restrictedList"/>

     <xs:simpleType name="list">
         <xs:list itemType="xs:decimal">
         </xs:list>
     </xs:simpleType>
     <xs:simpleType name="restrictedList">
         <xs:restriction base="list">
             <xs:length value="5"/>
         </xs:restriction>
     </xs:simpleType>
</xs:schema>

test.xml
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="test.xsd">8.5  6.54 3.11 6.76 
123.0</test>

 >Can a reference to a stylesheet be embededded in a schema
 > such as to say, "apply this transform to the data before validating"?

I'm not aware of something like this but there is Schematron that can be 
embedded in XML Schema and can be used to perform complex checks as it 
uses XPath.

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


kurt steele wrote:
> I have an XML document containing this set of fixed-length within a tag:
>  
> <?xml version="1.0"?>
> <data>8.5  6.54 3.11 6.76 123.0</data>
>  
> These are dew point readings from a sensor, each field is 5 bytes 
> long. What would be a schema for this instance?  Can a schema describe 
> untagged data?
>  
> The real data is complex, coming from many sensors and having a 
> structured hierarchy but the above sample articulates the use-case 
> adequately.  I do not want to tag every data element as bandwidth varies 
> greatly. 
>  
> Right now I let this lite XML to flow over the wireless connection then 
> use XSL to generate a fully tagged document. My schema describes 
> the latter.  Can a reference to a stylesheet be embededded in a schema 
> such as to say, "apply this transform to the data before validating"?
>  
> Thanks.
>  
> Kurt Steele
> Engineer
> Northrop-Grumman
>  
>  
>  
>  
>  
> 
>  
> 
>  
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
Received on Wednesday, 28 September 2005 06:46:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:51 GMT