XML Schema with String pattern gives error only in author mo

Having trouble installing Oxygen? Got a bug to report? Post it all here.
mxrenkin
Posts: 3
Joined: Fri Mar 06, 2009 2:08 am

XML Schema with String pattern gives error only in author mo

Post 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
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

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

Post 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
George Cristian Bina
Radu
Posts: 9438
Joined: Fri Jul 09, 2004 5:18 pm

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

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
mxrenkin
Posts: 3
Joined: Fri Mar 06, 2009 2:08 am

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

Post 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
Post Reply