XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
John HigginsSubject: Validation of element with attribute
Author: John Higgins
Date: 17 Jan 2006 09:39 AM
I am trying to construct a schema to validate an element with numeric data and a text attribute. I have enclosed the XML and schema files (the schema was generated by Stylus Studio). I need to check that the "coeff" data is numeric (running the validation gives a "valid" message) and the second element is obviously not. Is this format validatable with a schema? If so, how (I hacked several XSD attempts but got error messages)?

The forum has been very helpful in the past, so thanks in advance.


UnknownTest(12).xml
Test.xml

Unknowntest(3).xsd

Postnext
Tony LavinioSubject: Validation of element with attribute
Author: Tony Lavinio
Date: 17 Jan 2006 11:50 AM
Here is how you should do it:

<xs:element name="coeffs">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:double">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

As a side-point, 0.0D+00 will match an xs:double, but not an
xs:decimal, since expontiation is outside of the lexical space
for decimals. So I tweaked it so your sample XML file would
validate the number.

Posttop
John HigginsSubject: Validation of element with attribute
Author: John Higgins
Date: 17 Jan 2006 02:26 PM
Thanks Tony
As usual, worked like a charm.
John H

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.