OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] Using xsd:list and getting data from xml file

You can get access to this data without parsing it yourself by using schema-aware XQuery or XSLT 2.0. If you do this, the typed value of a vector4 element will be a sequence of four floats.
It's not hard to parse it yourself in non-schema-aware XQuery or XSLT 2.0 either - a simple call on tokenize() will do it for you.
Michael Kay

From: liam mail [mailto:liam.list@googlemail.com]
Sent: 18 February 2009 18:35
To: xml-dev@lists.xml.org
Subject: [xml-dev] Using xsd:list and getting data from xml file

Until recently I use the following format for a matrix
<matrix m01="1.000000" m02="0.000000" m03="0.000000" m04="0.000000" m05="0.000000" m06="1.000000" m07="0.000000" m08="0.000000" m09="0.000000" m10="0.000000" m11="1.000000" m12="0.000000" m13="0.000000" m14="0.000000" m15="0.000000" m16="1.000000" />

Yet after reading the schema primer I changed this to the following format
<vector4>1.000000 0.000000 0.000000 0.000000</vector4>
<vector4>0.000000 1.000000 0.000000 0.000000</vector4>
<vector4>0.000000 0.000000 1.000000 0.000000</vector4>
<vector4>0.000000 0.000000 0.000000 1.000000</vector4>

Which is validated by the following snippet of schema

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:element name="matrix16" type="matrix16_type"/>
<xsd:simpleType name="float_list">
<xsd:list itemType="xsd:float"/>

<xsd:simpleType name="vector4_type">
<xsd:restriction base="float_list">
<xsd:length value="4"/>

<xsd:complexType name="matrix16_type">
<xsd:element name="vector4" type="vector4_type" minOccurs="4" maxOccurs="4"/>

Now the xml file passes validation but I do not know of an xml libraries which allows me access to this data without myself
parsing it, as I was informed that "XML specifies that the innermost content of a tag is CDATA". If I used this list in an attribute of an
element the same situation would apply.

So my question to the mailing list is should I have changed the organisation of the xml from my original format or how can
I get to the data without having to parse it myself.

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS