Page 1 of 1

XML Schema with String pattern gives error only in author mo

Posted: Fri Dec 25, 2009 11:21 pm
by mxrenkin
Here is a simple example which produces an error in author mode, bud is valid in text mode:


Stylesheet.css:

Code: Select all


@charset "UTF-8";
Schema.xml:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
<xs:element name="SCRIBBLE">
<xs:complexType>
<xs:sequence>
<xs:element name="PROBLEM_DEMO">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value=".*\S\S\S.*"/>
<!--xs:whiteSpace value="collapse"></xs:whiteSpace-->
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
(xml.xsd in same directory)

Test XML Document:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="Stylesheet.css" type="text/css"?>
<SCRIBBLE xsi:noNamespaceSchemaLocation="Schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PROBLEM_DEMO>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a</PROBLEM_DEMO>
</SCRIBBLE>
When looking at the Text XML document in text-mode, everything is ok. But when switching to author mode, there is an error: "... not facet-valid with respect to pattern ...". The error goes away if reducing the length of the text (cutting one 'This is a test. " away). This problem is present since I am using OxygenXML (2 Years?)

Thanks in advance for checking that.

Max Renkin

Re: XML Schema with String pattern gives error only in author mo

Posted: Sat Dec 26, 2009 12:01 am
by george
Dear Max,

The problem is that the document is serialized from the Author in order to be validated and the formatting that is applied destroys the text from the PROBLEM_DEMO element. You can see that if you make an irrelevant change in the author and then move to Text mode - you will be even able to reproduce the same error message.

The solution is to enable the "Preserve space as it is" option from Options->Preferences -- Editor / Format / XML.

Best Regards,
George

Re: XML Schema with String pattern gives error only in author mo

Posted: Mon Dec 28, 2009 10:47 am
by Radu
Hi,

Another solution is to specify the PROBLEM_DEMO as space preserve in the Stylesheet.css:

Code: Select all


PROBLEM_DEMO{
white-space:pre-wrap;
}
Regards,
Radu

Re: XML Schema with String pattern gives error only in author mo

Posted: Tue Dec 29, 2009 2:43 am
by mxrenkin
Many Thanks!

I used the 2nd solution (by Radu), since it is more convenient in my case. Everything is fine now.

Best Regards

Max