A
Ashton
Hello,
I am fairly new to all this XML stuff. I have recently taken over
some coding on a project that involves reading in xml documents and
validating them based on some schema files. The schema files were
written long before I started working on the program, so I had no
input in their creation. We created a tool that uses MSXML to load
and validate the documents. 99% of it works great. The last 1% is
stumping me. There are a couple of elements that we want to hold some
plain text. The .xsd and .xml documents were edited in XMLSpy and
validate just fine. When I use my tool, however, it says that the
Pattern constraint failed, and the element has an invalid value
according to it's data type. The schema contains
....
<!-- =========== -->
<xs:simpleType name="TextSubjectString">
<xs:annotation>
<xs:documentation>String data.</xs:documentation>
</xs:annotation>
<xs:restriction base="UsAsciiPrintableString">
<xs:minLength value="1"/>
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<!-- =========== -->
<xs:simpleType name="UsAsciiPrintableString">
<xs:annotation>
<xs:documentation>Unformatted text.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xsattern value="[\p{IsBasicLatin}-[\p{C}]]*"/>
</xs:restriction>
</xs:simpleType>
<!-- =========== -->
In XMLSpy, pretty much any string of the appropriate length works
fine. In my tool (and another tool that uses MSXML4) it will only
validate successfully if the value is a single character.
Since I haven't worked with XML very long, I don't know if the pattern
in the schema is right. It just seems strange to me that XMLSpy is
okay with it, but MSXML fails.
Thanks for any input.
Ashton
I am fairly new to all this XML stuff. I have recently taken over
some coding on a project that involves reading in xml documents and
validating them based on some schema files. The schema files were
written long before I started working on the program, so I had no
input in their creation. We created a tool that uses MSXML to load
and validate the documents. 99% of it works great. The last 1% is
stumping me. There are a couple of elements that we want to hold some
plain text. The .xsd and .xml documents were edited in XMLSpy and
validate just fine. When I use my tool, however, it says that the
Pattern constraint failed, and the element has an invalid value
according to it's data type. The schema contains
....
<!-- =========== -->
<xs:simpleType name="TextSubjectString">
<xs:annotation>
<xs:documentation>String data.</xs:documentation>
</xs:annotation>
<xs:restriction base="UsAsciiPrintableString">
<xs:minLength value="1"/>
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<!-- =========== -->
<xs:simpleType name="UsAsciiPrintableString">
<xs:annotation>
<xs:documentation>Unformatted text.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xsattern value="[\p{IsBasicLatin}-[\p{C}]]*"/>
</xs:restriction>
</xs:simpleType>
<!-- =========== -->
In XMLSpy, pretty much any string of the appropriate length works
fine. In my tool (and another tool that uses MSXML4) it will only
validate successfully if the value is a single character.
Since I haven't worked with XML very long, I don't know if the pattern
in the schema is right. It just seems strange to me that XMLSpy is
okay with it, but MSXML fails.
Thanks for any input.
Ashton