Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Newbie Can't Get XSD Schema To Validate

Status
Not open for further replies.

Zandoaxr

Programmer
Jul 8, 2010
3
0
0
US
Using an XML for beginners book, I can't get an XML file and XSD schema copied directly from the book to validate, and its bugging the hell out of me. Here are the key parts of the code the Validator (... keeps showing to be in error:

XML:
<painting paintingID="123-4567-890">

XSD:
(...missing code...)
<xsd:attribute name="paintingID" type="catalogID" />
(...missing code...)
<xsd:simpleType name="catalogID">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-\d{4}-\d{3}" />
</xsd:restriction>
</xsd:simpleType>

Error Messages:
cvc-attribute.3: The value '123-4567-890' of attribute 'paintingID' on element 'painting' is not valid with respect to its type, 'catalogID'.

cvc-pattern-valid: Value '123-4567-890' is not facet-valid with respect to pattern '\\d{3}\\-\\d{4}\\-\\d{3}' for type 'catalogID'.

Being new to this, I'm sure I'm missing something simple, but I've checked and rechecked the XML and XSD codes multiple times against what's in the book and it's exactly the same. Any thoughts?
 
>cvc-pattern-valid: Value '123-4567-890' is not facet-valid with respect to pattern '\\d{3}\\-\\d{4}\\-\\d{3}' for type 'catalogID'.
If the SAXParseException has got this message to say, it sounds like your xsd has the pattern scripted with all those double backslash as well as escaping the 'hyphen'. It should not be.
 
tsuji -

Thank you for responding. I just realized that I put the wrong Error Messages on my request (...I was trying something that didn't work...). Here are the correct Error Messages:
--------------------------------------------
cvc-attribute.3: The value '123-4567-890' of attribute 'paintingID' on element 'painting' is not valid with respect to its type, 'catalogID'.

cvc-pattern-valid: Value '123-4567-890' is not facet-valid with respect to pattern '\\d{3}-\\d{4}-\\d{3}' for type 'catalogID'.
--------------------------------------------

I don't know why the Validator error messages throw in extra forward-slashes and replace quote-marks with hyphens. Except for this one segment of code, everything else in my XMS/XSD validates.

If anyone has an explanation for why I'm getting this error, please give it to me in dumbed-down language. I'm experienced in HTML, CSS, and JavaScript, but am just beginning to teach myself XML. Thanks!
 
I don't see any difference in the error messages, so why repeat the same? As the error messages are the same, my answer to it is the same. Check your xsd.
 
Tsuji -

After repeated, unsuccessful efforts on my work computer to get the XML and XSD schema to validate, I took the code home to work on it. Without changing anything in the code, I entered the XML and XSD in the same Validator (... and it came out perfect! The only difference was that I accessed the Validator through Google Chrome instead of IE8. How bizzare is that?

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top