Validating NSXMLDocument with xml:space attributes
Validating NSXMLDocument with xml:space attributes
- Subject: Validating NSXMLDocument with xml:space attributes
- From: Heath Borders <email@hidden>
- Date: Mon, 07 Mar 2011 15:09:07 -0600
I have the following document:
<root xmlns="http://example.com/root"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.com/root root.xsd"><foo
xml:space="preserve"> there is leading and trailing whitespace here
</foo></root>
With the following XSD:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/root"
xmlns="http://example.com/root">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd" />
<!-- Complex types describing all parts of the document -->
<xs:complexType name="fooType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="xml:space" fixed="preserve" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- The actual schema itself -->
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="fooType"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
When I try to validate by reading in my document and then calling:
NSXMLDocument *document = ...
NSError *error = nil;
[document validateAndReturnError:&error];
I always get the following errors:
Element '{http://example.com}foo', attribute 'space': The attribute
'space' is not allowed.
Element '{http://example.com}foo', attribute 'space': The attribute
'space' is not allowed.
Element '{http://example.com}foo', attribute 'space': The attribute
'space' is not allowed.
-Heath Borders
email@hidden
Twitter: heathborders
http://heath-tech.blogspot.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden