XML Validator Mistaken?

P

Peter

Hi,

I think the XML validator in VB is screwing up somehow. Not sure what the
problem is. I have a line in an XML file that reads:

<PXPPaperColor color="ff928a" name="Cherry"></PXPPaperColor>

The XSD statements corresponding to the "color" attribute are:

<xs:attribute name="color" type="hexColor" use="required" />

and

<xs:simpleType name="hexColor">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9a-f]^6" />
</xs:restriction>

When I validate this using the XML menu, I get an error at the position of
that PXPPaperColor color sttribute: "The 'color' attribute has an invalid
value according to its data type."...

No, it doesn't. I can even do a search in the XML file using the regular
expression [0-9a-f]^6 and it finds the value of my color attribute. What's
going on here? Why is the XML validator missing that?
 
P

Peter

<xs:restriction base="xs:string">
<xs:pattern value="[0-9a-f]^6" />

That is not the proper syntax I think, if you want to allow exactly six
hex digits then you need
<xs:pattern value="[0-9a-f]{6}"/>

I've tried it both ways; it makes no difference to the error encountered.
 
P

Peter

<xs:restriction base="xs:string">
<xs:pattern value="[0-9a-f]^6" />

That is not the proper syntax I think, if you want to allow exactly six
hex digits then you need
<xs:pattern value="[0-9a-f]{6}"/>

I've tried it both ways; it makes no difference to the error encountered.

Well, I'll be. That fixed it. Of course, I've changed so many other things
around since I first tried it, I bet I fixed the real problem a while ago
and was just left with the wrong format.

I will say, though, that the documentation has it wrong. In describing the
"^n" expression, I quote Microsoft:

"Matches n occurrences of the preceding expression. For example, [0-9]^4
matches any 4-digit sequence."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

xsd:maxLength 1
parseing an xml string 4
Calling SOAP Method from VB.NET 0
Populate Typed DataSet with XML Problem 1
XSD validation Error 1
NEsted XML output 2
XSD question 10
Need help for xml schema 2

Top