You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2010/07/05 04:19:49 UTC
[jira] Commented: (XERCESJ-1456) Regular expression is incorrectly
handled in pattern facet
[ https://issues.apache.org/jira/browse/XERCESJ-1456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12885091#action_12885091 ]
Michael Glavassevich commented on XERCESJ-1456:
-----------------------------------------------
Khaled, I think this may be related to your fix for XERCESJ-589. Please take a look.
> Regular expression is incorrectly handled in pattern facet
> ----------------------------------------------------------
>
> Key: XERCESJ-1456
> URL: https://issues.apache.org/jira/browse/XERCESJ-1456
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.0 Datatypes
> Affects Versions: 2.10.0
> Environment: JDK 1.5.0
> Reporter: Christian Schröder
> Assignee: Khaled Noaman
>
> I have the following schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:element name="test" type="Test"/>
> <xsd:simpleType name="Test">
> <xsd:restriction base="xsd:string">
> <xsd:pattern value="[0-9]{0,3}([0-9]{3})*"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:schema>
> And this xml file:
> <?xml version="1.0" encoding="windows-1252"?>
> <test>1010000</test>
> I try to validate the file with the following test code:
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> dbf.setNamespaceAware(true);
> DocumentBuilder builder = dbf.newDocumentBuilder();
> Document xsd = builder.parse(Main.class.getResource("/test.xsd").toString());
> SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
> Schema schema = sf.newSchema(new DOMSource(xsd));
> Validator validator = schema.newValidator();
> Document test = builder.parse(Main.class.getResource("/test.xml").toString());
> validator.validate(new DOMSource(test));
> I get an org.xml.sax.SAXParseException: cvc-pattern-valid: Value '1010000' is not facet-valid with respect to pattern '[0-9]{0,3}([0-9]{3})*' for type 'Test'.
> In my opinion, the given value should be valid for the given pattern. Even the following code prints "true":
> RegularExpression re = new RegularExpression("[0-9]{0,3}([0-9]{3})*");
> System.out.println(re.matches("1010000"));
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org