...

View Full Version : JavaScript RegExp and XML schema patterns



dakkar
04-21-2005, 03: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!

codegoboom
04-22-2005, 02: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.

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

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

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

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

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

codegoboom
04-22-2005, 03: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).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum