[JIRA] Commented: (JAXP-78) validation fails to complain on white-space around tokens

  • From: "Franta Mejta (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [JIRA] Commented: (JAXP-78) validation fails to complain on white-space around tokens
  • Date: Fri, 4 Oct 2013 12:52:17 +0000 (UTC)
  • Auto-submitted: auto-generated


    [ 
https://java.net/jira/browse/JAXP-78?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=369296#action_369296
 ] 

Franta Mejta commented on JAXP-78:
----------------------------------

The value of "Organisation " is completely ok for xsd:token. See 
http://www.xmlplease.com/normalized.

> validation fails to complain on white-space around tokens
> ---------------------------------------------------------
>
>                 Key: JAXP-78
>                 URL: https://java.net/jira/browse/JAXP-78
>             Project: jaxp
>          Issue Type: Bug
>         Environment: javac 1.7.0_21 Ubuntu 12.04.2
>            Reporter: m_perdikeas
>
> You can try this usecase with:
> git clone 
> https://github.com/mperdikeas/jaxp-validation-space-around-token.git && cd ;
> jaxp-validation-space-around-token && ant
> The code executes and validates the *a.xml* instance document although, 
> given the *A.xsd* grammer, it should have complained due to the extra 
> whitespace.
> This was originally reported to JAXB's bugtracker:
> https://java.net/jira/browse/JAXB-964
> But the engineer responsible suggested that I report it to JAXP instead.
> Crux of the matter is that I have a type defined as a token in XSD and in 
> an instance document an enumerated value appears with whitespace around it 
> and the validation doesn't complain although it should:
> {quote}
> From XML Schema Part 2: Datatypes Second Edition, section 3.3.2, token:
> [Definition:] token represents tokenized strings. The - value space-  of 
> token is the set of strings that do not contain the carriage return (#xD), 
> line feed (#xA) nor tab (#x9) characters, that have no leading or trailing 
> spaces (#x20) and that have no internal sequences of two or more spaces.
> {quote}
> Files follow:
> h2.A.xsd
> <xs:schema targetNamespace="foo://a" 
>            xmlns:xs="http://www.w3.org/2001/XMLSchema" ;
>            xmlns="foo://a">
>    <xs:element name="type" type="Type"/>
>    <xs:simpleType name="Type">
>      <xs:restriction base="xs:token">
>          <xs:enumeration value="Archive"/>
>          <xs:enumeration value="Organisation"/>
>        </xs:restriction>
>    </xs:simpleType>
> </xs:schema>
> h2.a.xml
> <a:type xmlns:a="foo://a" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="foo://a A.xsd"
> >Organisation </a:type>
> (notice the space after 'Organization')
> h2.Java validating code
> import java.io.IOException;
> import java.io.BufferedReader;
> import java.io.InputStreamReader;
> import java.io.InputStream;
> import java.io.ByteArrayInputStream;
> import java.io.File;
> import javax.xml.XMLConstants;
> import org.xml.sax.SAXException;
> import org.xml.sax.InputSource;
> import javax.xml.transform.sax.SAXSource;
> import javax.xml.validation.Validator;
> import javax.xml.validation.SchemaFactory;
> import javax.xml.validation.Schema;
> import javax.xml.transform.Source;
> import javax.xml.transform.stream.StreamSource;
> import java.nio.file.Files;
> import java.nio.file.Paths;
> import java.nio.charset.StandardCharsets;
> import java.nio.ByteBuffer;
> public class FooMain {
>     public static void main(String args[]) throws Exception {
>         SchemaFactory schemaFactory = 
> SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
>         Schema SCHEMA = 
> SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema( 
> new StreamSource(new File("A.xsd")));
>         Validator validator = SCHEMA.newValidator();
>         SAXSource source = new SAXSource(new InputSource(new 
> ByteArrayInputStream(
>                               
> StandardCharsets.UTF_8.decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("a.xml")))).toString().getBytes())));
>         try {
>             validator.validate(source);
>             System.out.println("validates");
>         }  catch (SAXException e) {
>             System.out.println("doesn't validate");
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Commented: (JAXP-78) validation fails to complain on white-space around tokens

Franta Mejta (JIRA) 10/04/2013
Terms of Use; Privacy Policy; Copyright ©2013-2015 (revision 20150226.965aeb8)
 
 
Close
loading
Please Confirm
Close