Skip to main content



      Home
Home » Modeling » EMF » Leading whitespace is not removed when parsing list element(When parsing an XML document with leading whitespace in a list, the document is considered illegal)
Leading whitespace is not removed when parsing list element [message #1207169] Sun, 24 November 2013 07:26 Go to next message
Eclipse UserFriend
Hi,

I believe there is still a problem with parsing list elements - leading whitespace is not skipped.

This problem is very similar to http://www.eclipse.org/forums/index.php?t=msg&goto=846629
and the resulting bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=376967 .

The solution was to change pattern used in the EFactoryImpl method split method
from "[ \t\n\r\f]" to "[ \t\n\r\f]+" - however, Pattern.split will return a leading
empty String, if the pattern is found in the beginning of the target string,
so the solution is not quite adequate?

Please see example below, and the enclosed Eclipse project.

I have validated the XSD/XML successfully at http://www.freeformatter.com/xml-validator-xsd.html

EMF is 2.9.1.v20130902-0605 and Eclipse is 4.3.1.M20130911-1000, under Linux Mint 14 (64 bit).

- Jan


XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org/testmodel/" targetNamespace="http://www.example.org/testmodel/">

<xs:simpleType name="ListOfFloats">
<xs:list itemType="xs:float" />
</xs:simpleType>

<xs:simpleType name="float2x2">
<xs:restriction base="ListOfFloats">
<xs:minLength value="4" />
<xs:maxLength value="4" />
</xs:restriction>
</xs:simpleType>

<xs:element name="matrix">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="float2x2">
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="matrix" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>


XML - first and second matrix is ok, third and fourth fails validation:

<?xml version="1.0" encoding="UTF-8"?>
<root
xmlns="http://www.example.org/testmodel/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/testmodel/ ../../model/testmodel.xsd ">

<matrix>1.0 0.0 0.0 1.0</matrix>

<matrix>1.1 0.1
0.1 1.1
</matrix>

<matrix> 1.2 0.2
0.2 1.2
</matrix>

<matrix>
1.3 0.3
0.3 1.3
</matrix>
</root>
Re: Leading whitespace is not removed when parsing list element [message #1207478 is a reply to message #1207169] Sun, 24 November 2013 11:03 Go to previous messageGo to next message
Eclipse UserFriend
Jan,

Please open a bugzilla.

On 24/11/2013 1:26 PM, Jan Schoubo wrote:
> Hi,
>
> I believe there is still a problem with parsing list elements - leading whitespace is not skipped.
>
> This problem is very similar to http://www.eclipse.org/forums/index.php?t=msg&goto=846629
> and the resulting bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=376967 .
>
> The solution was to change pattern used in the EFactoryImpl method split method
> from "[ \t\n\r\f]" to "[ \t\n\r\f]+" - however, Pattern.split will return a leading
> empty String, if the pattern is found in the beginning of the target string,
> so the solution is not quite adequate?
>
> Please see example below, and the enclosed Eclipse project.
>
> I have validated the XSD/XML successfully at http://www.freeformatter.com/xml-validator-xsd.html
>
> EMF is 2.9.1.v20130902-0605 and Eclipse is 4.3.1.M20130911-1000, under Linux Mint 14 (64 bit).
>
> - Jan
>
>
> XSD:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.example.org/testmodel/" targetNamespace="http://www.example.org/testmodel/">
>
> <xs:simpleType name="ListOfFloats">
> <xs:list itemType="xs:float" />
> </xs:simpleType>
>
> <xs:simpleType name="float2x2">
> <xs:restriction base="ListOfFloats">
> <xs:minLength value="4" />
> <xs:maxLength value="4" />
> </xs:restriction>
> </xs:simpleType>
>
> <xs:element name="matrix">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="float2x2">
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
>
> <xs:element name="root">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="matrix" minOccurs="1" maxOccurs="unbounded" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
>
>
> XML - first and second matrix is ok, third and fourth fails validation:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root
> xmlns="http://www.example.org/testmodel/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.example.org/testmodel/ ../../model/testmodel.xsd ">
>
> <matrix>1.0 0.0 0.0 1.0</matrix>
>
> <matrix>1.1 0.1
> 0.1 1.1
> </matrix>
>
> <matrix> 1.2 0.2
> 0.2 1.2
> </matrix>
>
> <matrix>
> 1.3 0.3
> 0.3 1.3
> </matrix>
> </root>
>
Re: Leading whitespace is not removed when parsing list element [message #1207708 is a reply to message #1207478] Sun, 24 November 2013 13:44 Go to previous message
Eclipse UserFriend
Ok, I have created https://bugs.eclipse.org/bugs/show_bug.cgi?id=422416 - hope I got it right?

- Jan
Previous Topic:CDO model evolution strategy
Next Topic:[Texo] How to prevent the generator from generating entity name annotation
Goto Forum:
  


Current Time: Wed Jul 23 14:50:45 EDT 2025

Powered by FUDForum. Page generated in 0.03687 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top