View Full Version : JavaScript RegExp and XML schema patterns

04-21-2005, 04:48 PM
Hi all!

I've a little-big question:

can I use Javascript regexp to validate an XML schema pattern?

do they have the same syntax? (If I remember they have the PERL regex syntax)...

In conclusion:
Can I "copy" a XML schema pattern to a javascript, and use it as regexp?

I need some experts to answer this question!
Thank you in advance!

04-22-2005, 03:55 AM
do they have the same syntax?
Schema (http://msdn.microsoft.com/library/en-us/xmlsdk/html/xsdrefxmlschemaregularexpressionsreferencechart.asp) & JS (http://msdn.microsoft.com/library/en-us/script56/html/js56jsgrpregexpsyntax.asp) expressions are apparently not identical.

04-22-2005, 04:43 PM
uhm... ouch!

Any idea on how to do this job? :_(

04-22-2005, 04:50 PM
well... but... this:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="zips">
<xs:sequence maxOccurs="unbounded">
<xs:element name="zip" type="better-us-zipcode"></xs:element>
<xs:simpleType name="better-us-zipcode">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{5}(-[0-9]{4})?"/>

If I use the above pattern... it works... no?

04-22-2005, 04:55 PM
Any idea on how to do this job?
My idea would be to use JS only to run the SOM automation object neeeded to handle the regular expression, and return something... (if that's possible).