DavidDunn
asked on
MSXML/W3C pattern value problem
I am using MSXML Parser v4.0 which supports W3C XSD schemas.
When I validate XML against a schema is correctly validates the minLength and maxLength values, however, it appears to completely ignore the pattern value.
I have tried numerous patterns like "\d{32}", "[0-9]{32}" etc. but they do not work.
Any ideas?
When I validate XML against a schema is correctly validates the minLength and maxLength values, however, it appears to completely ignore the pattern value.
I have tried numerous patterns like "\d{32}", "[0-9]{32}" etc. but they do not work.
Any ideas?
Hi David Dunn
Please specify the full code in the comments and then I will look at it and then I will be able to tell you what can be the problem?
Regards,
Ashish
Please specify the full code in the comments and then I will look at it and then I will be able to tell you what can be the problem?
Regards,
Ashish
David,
Yes, it's true. See "what's new" section in the SDK documentation:
> The MSXML 4.0 Technology Preview does not support regular expressions and identity constraints.
Yes, it's true. See "what's new" section in the SDK documentation:
> The MSXML 4.0 Technology Preview does not support regular expressions and identity constraints.
ASKER
XML
========================== ========== ========== ===
<?xml version="1.0" encoding="UTF-8"?>
<test:Sample xmlns:test="urn:Func">
<ID>ZZDDDDDDDDDXDDDDDDDDDD DDWDDDDDDD </ID>
</test:Sample>
========================== ========== ========== ===
XSD
========================== ========== ========== ===
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="typID">
<xsd:restriction base="xsd:string">
<xsd:minLength value="32"/>
<xsd:pattern value="[0-9]{32}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="typSample">
<xsd:sequence>
<xsd:element name="ID" type="typID"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Sample" type="typSample"/>
</xsd:schema>
========================== ========== ========== ===
VB Code
========================== ========== ========== ===
Private mobjDOM As New DOMDocument40
Private mobjSchema As New XMLSchemaCache40
Private Sub Command1_Click()
mobjSchema.Add "urn:Func", "c:\test\func.xsd"
mobjDOM.async = False
Set mobjDOM.schemas = mobjSchema
mobjDOM.Load "c:\test\id.xml"
If mobjDOM.parseError.errorCo de <> 0 Then
MsgBox mobjDOM.parseError.reason
Else
MsgBox "OK"
End If
End Sub
========================== ========== ========== ===
==========================
<?xml version="1.0" encoding="UTF-8"?>
<test:Sample xmlns:test="urn:Func">
<ID>ZZDDDDDDDDDXDDDDDDDDDD
</test:Sample>
==========================
XSD
==========================
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="typID">
<xsd:restriction base="xsd:string">
<xsd:minLength value="32"/>
<xsd:pattern value="[0-9]{32}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="typSample">
<xsd:sequence>
<xsd:element name="ID" type="typID"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Sample" type="typSample"/>
</xsd:schema>
==========================
VB Code
==========================
Private mobjDOM As New DOMDocument40
Private mobjSchema As New XMLSchemaCache40
Private Sub Command1_Click()
mobjSchema.Add "urn:Func", "c:\test\func.xsd"
mobjDOM.async = False
Set mobjDOM.schemas = mobjSchema
mobjDOM.Load "c:\test\id.xml"
If mobjDOM.parseError.errorCo
MsgBox mobjDOM.parseError.reason
Else
MsgBox "OK"
End If
End Sub
==========================
ASKER
Yury_Delendik,
Not the answer I wanted to hear, but I thought it might be the case.
As this is only a preview version, do you know if the release version of MSXML 4 will contain this functionality?
Not the answer I wanted to hear, but I thought it might be the case.
As this is only a preview version, do you know if the release version of MSXML 4 will contain this functionality?
ASKER
Also,
Is there another parser which I can use that will perform this validation?
Thanks.
Is there another parser which I can use that will perform this validation?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please post your schema and an example XML document.
Regards,
WMB