You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Benjamin Keil <bk...@humnet.ucla.edu> on 2006/05/01 03:54:01 UTC

Validating a document against a schema that contains inline SVGs

Hello all,

  I'm trying to put together a schema that would allow inline SVG
elements, but I'm having a lot of trouble making this work.

The main problem seems to be coming from the SVG schema
(from http://www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd )

I am loading documents like this:

DocumentBuilderFactory factory = new
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
factory.setFeature("http://apache.org/xml/features/validation/schema",
true);
factory.setFeature("http://xml.org/sax/features/validation", true);	
factory.setFeature("http://xml.org/sax/features/namespaces", true);
factory.setNamespaceAware(true);

DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(source);

Even trying to validate a little document like this:

<?xml version="1.0" encoding="UTF-8"?>
<svg:svg height="10cm" width="11cm" viewBox="0 0 1100 1000"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.w3.org/2000/svg svg.xsd ">

	<svg:rect x="1" y="1" width="1098" height="998" fill="none"
stroke="blue" stroke-width="2" />

</svg:svg>

leads to an impressive array of errors (at the end of this email).

Is there a problem with my configuration?  Is there a problem with the
SVG schema?  Is a working SVG schema available from anywhere else?
Without a working SVG schema is it possible to define an schema that
allows inline SVG content similar to this:

<xs:complexType name="mapEntryType">
	<xs:sequence>
		<xs:element ref="svg:svg" />
	</xs:sequence>
</xs:complexType>

Thanks in advance for any help,
Benjamin Keil.


[Error] svg.xsd:344:61: s4s-att-not-allowed: Attribute 'type' cannot
appear in element 'attribute'.
[Error] xlink.xsd:21:55: s4s-att-not-allowed: Attribute 'use' cannot
appear in element 'attribute'.
[Error] xlink.xsd:22:58: s4s-att-not-allowed: Attribute 'use' cannot
appear in element 'attribute'.
[Error] xlink.xsd:23:56: s4s-att-not-allowed: Attribute 'use' cannot
appear in element 'attribute'.
[Error] svg.xsd:845:63: s4s-att-not-allowed: Attribute 'type' cannot
appear in element 'attribute'.
[Error] xlink.xsd:20:55: s4s-att-not-allowed: Attribute 'use' cannot
appear in element 'attribute'.
[Error] svg.xsd:1108:107: cvc-pattern-valid: Value 'xMidYMid meet' is
not facet-valid with respect to pattern
'(\s*("none"|x("Min"|"Mid"|"Max")y("Min"|"Mid"|"Max"))\s+("meet"|"slice")?\s*)'
for type 'PreserveAspectRatioSpecType'.
[Error] svg.xsd:1108:107: a-props-correct.2: Invalid value constraint
value 'xMidYMid meet' in attribute 'preserveAspectRatio'.
[Error] svg.xsd:1294:107: cvc-pattern-valid: Value 'xMidYMid meet' is
not facet-valid with respect to pattern
'(\s*("none"|x("Min"|"Mid"|"Max")y("Min"|"Mid"|"Max"))\s+("meet"|"slice")?\s*)'
for type 'PreserveAspectRatioSpecType'.
[Error] svg.xsd:1294:107: a-props-correct.2: Invalid value constraint
value 'xMidYMid meet' in attribute 'preserveAspectRatio'.
[Error] svg.xsd:1299:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1326:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1356:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1399:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1425:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1454:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1480:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1507:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1535:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1560:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1856:107: cvc-pattern-valid: Value 'xMidYMid meet' is
not facet-valid with respect to pattern
'(\s*("none"|x("Min"|"Mid"|"Max")y("Min"|"Mid"|"Max"))\s+("meet"|"slice")?\s*)'
for type 'PreserveAspectRatioSpecType'.
[Error] svg.xsd:1856:107: a-props-correct.2: Invalid value constraint
value 'xMidYMid meet' in attribute 'preserveAspectRatio'.
[Error] svg.xsd:1874:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1878:63: s4s-att-not-allowed: Attribute 'type' cannot
appear in element 'attribute'.
[Error] svg.xsd:1895:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:1935:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:2036:107: cvc-pattern-valid: Value 'xMidYMid meet' is
not facet-valid with respect to pattern
'(\s*("none"|x("Min"|"Mid"|"Max")y("Min"|"Mid"|"Max"))\s+("meet"|"slice")?\s*)'
for type 'PreserveAspectRatioSpecType'.
[Error] svg.xsd:2036:107: a-props-correct.2: Invalid value constraint
value 'xMidYMid meet' in attribute 'preserveAspectRatio'.
[Error] svg.xsd:2054:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:2162:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:2316:71: ct-props-correct.4: Error for type
'feFuncRType'. Duplicate attribute uses with the same name and target
namespace are specified.  Name of duplicate attribute use is 'type'.
[Error] svg.xsd:2335:71: ct-props-correct.4: Error for type
'feFuncGType'. Duplicate attribute uses with the same name and target
namespace are specified.  Name of duplicate attribute use is 'type'.
[Error] svg.xsd:2354:71: ct-props-correct.4: Error for type
'feFuncBType'. Duplicate attribute uses with the same name and target
namespace are specified.  Name of duplicate attribute use is 'type'.
[Error] svg.xsd:2374:71: ct-props-correct.4: Error for type
'feFuncAType'. Duplicate attribute uses with the same name and target
namespace are specified.  Name of duplicate attribute use is 'type'.
[Error] svg.xsd:2692:107: cvc-pattern-valid: Value 'xMidYMid meet' is
not facet-valid with respect to pattern
'(\s*("none"|x("Min"|"Mid"|"Max")y("Min"|"Mid"|"Max"))\s+("meet"|"slice")?\s*)'
for type 'PreserveAspectRatioSpecType'.
[Error] svg.xsd:2692:107: a-props-correct.2: Invalid value constraint
value 'xMidYMid meet' in attribute 'preserveAspectRatio'.
[Error] svg.xsd:2734:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:2792:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] svg.xsd:2936:57: cos-all-limited.1.2: An 'all' model group must
appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and
that particle must be part of a pair which constitutes the '{'content
type'}' of a complex type definition.
[Error] xlink.xsd:45:55: s4s-att-not-allowed: Attribute 'use' cannot
appear in element 'attribute'.
[Error] xlink.xsd:46:53: s4s-att-not-allowed: Attribute 'use' cannot
appear in element 'attribute'.

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validating a document against a schema that contains inline SVGs

Posted by Prashant <pr...@pramati.com>.
Oops!

    xsi:schemaLocation="http://www.w3.org/2000/svg svg.xsd

does contain the schema location hint and target namespace. I should 
have been paying more attention. :)

-Prashant

Prashant wrote:

>
>> Hello all,
>>
>> <snip>
>>
>> I am loading documents like this:
>>
>> DocumentBuilderFactory factory = new
>> org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
>> factory.setFeature("http://apache.org/xml/features/validation/schema",
>> true);
>> factory.setFeature("http://xml.org/sax/features/validation", true);   
>> factory.setFeature("http://xml.org/sax/features/namespaces", true);
>> factory.setNamespaceAware(true);
>>
>> DocumentBuilder builder = factory.newDocumentBuilder();
>> Document doc = builder.parse(source);
>>
>> Even trying to validate a little document like this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <svg:svg height="10cm" width="11cm" viewBox="0 0 1100 1000"
>> xmlns:svg="http://www.w3.org/2000/svg"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>     xsi:schemaLocation="http://www.w3.org/2000/svg svg.xsd ">
>>
>>     <svg:rect x="1" y="1" width="1098" height="998" fill="none"
>> stroke="blue" stroke-width="2" />
>>
>> </svg:svg>
>>  
>>
> Should't the xsi:schemaLocation contain pairs of values: The first 
> member of each pair is the namespace for which the second member is 
> the hint describing where to find to an appropriate schema document.
>
> At the risk of hijacking this thread, I would like to know how the 
> parser could locate the schema definition using the above sited piece 
> of code that did not supply its own external schema location ?
>
> I would have expected the parser to fail with "Cannot find the 
> declaration of element 'svg'".
>
> -Prashant
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validating a document against a schema that contains inline SVGs

Posted by Prashant <pr...@pramati.com>.
>Hello all,
>
><snip>
>
>I am loading documents like this:
>
>DocumentBuilderFactory factory = new
>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
>factory.setFeature("http://apache.org/xml/features/validation/schema",
>true);
>factory.setFeature("http://xml.org/sax/features/validation", true);	
>factory.setFeature("http://xml.org/sax/features/namespaces", true);
>factory.setNamespaceAware(true);
>
>DocumentBuilder builder = factory.newDocumentBuilder();
>Document doc = builder.parse(source);
>
>Even trying to validate a little document like this:
>
><?xml version="1.0" encoding="UTF-8"?>
><svg:svg height="10cm" width="11cm" viewBox="0 0 1100 1000"
>xmlns:svg="http://www.w3.org/2000/svg"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>	xsi:schemaLocation="http://www.w3.org/2000/svg svg.xsd ">
>
>	<svg:rect x="1" y="1" width="1098" height="998" fill="none"
>stroke="blue" stroke-width="2" />
>
></svg:svg>
>  
>
Should't the xsi:schemaLocation contain pairs of values: The first 
member of each pair is the namespace for which the second member is the 
hint describing where to find to an appropriate schema document.

At the risk of hijacking this thread, I would like to know how the 
parser could locate the schema definition using the above sited piece of 
code that did not supply its own external schema location ?

I would have expected the parser to fail with "Cannot find the 
declaration of element 'svg'".

-Prashant

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validating a document against a schema that contains inline SVGs

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Benjamin Keil <bk...@humnet.ucla.edu> wrote on 04/30/2006 09:54:01 PM:

> Hello all,
> 
>   I'm trying to put together a schema that would allow inline SVG
> elements, but I'm having a lot of trouble making this work.
> 
> The main problem seems to be coming from the SVG schema
> (from http://www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd )

This schema document has a DTD (XMLSchema.dtd) which references another 
document (datatypes.dtd) that doesn't exist at the specified location. The 
working draft of SVG [1] you're using says: "this schema is still in 
development and is being tested" so it's possible there were other 
problems with this version.

error: Parse error occurred - 
http://www.w3.org/TR/2002/WD-SVG11-20020108/datatypes.dtd
java.io.FileNotFoundException: 
http://www.w3.org/TR/2002/WD-SVG11-20020108/datatypes.dtd
        at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:682)
        at 
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:959)
        at 
org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:871)
        at 
org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:809)
        at 
org.apache.xerces.impl.XMLDTDScannerImpl.startPE(XMLDTDScannerImpl.java:640)
        at 
org.apache.xerces.impl.XMLDTDScannerImpl.skipSeparator(XMLDTDScannerImpl.java:2022)
        at 
org.apache.xerces.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:1984)
        at 
org.apache.xerces.impl.XMLDTDScannerImpl.scanDTDExternalSubset(XMLDTDScannerImpl.java:276)
        at 
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:993)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:323)
        at 
org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:844)
        at 
org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:767)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:107)
        at 
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1127)

<snip/>

> Thanks in advance for any help,
> Benjamin Keil.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

[1] http://www.w3.org/TR/2002/WD-SVG11-20020108/#schema

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org