[xml] Changes in relaxng error reporting



Title: signature
Hello,

Working on a project I just discovered an interesting "feature" in libxml2.

In version of the library prior to 2.7.4 if we had a relaxng schema that defines type with additional validation in regular _expression_ format in case when type validation fails library would report two errors:
XML_RELAXNG_ERR_TYPEVAL
XML_RELAXNG_ERR_CONTENTVALID

which is great

But in version starting from 2.7.4 and onwards library reports only
XML_RELAXNG_ERR_CONTENTVALID

Is there a way to get back the old behaviour?

Here is a sample xml and relaxng schema to demonstrate this:
//sample.xml start

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<root xmlns="http://www.idpf.org/2007/opf">
ÂÂÂ <items>
ÂÂÂÂÂÂÂ <item href="" />
ÂÂÂÂÂÂÂ <item href="" />Â
ÂÂÂ </items>
</root>
//sample.xml end

//sample.rng start
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
ÂÂÂÂÂÂÂÂ ns="http://www.idpf.org/2007/opf"
ÂÂÂÂÂÂÂÂ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

<start>
 <ref name="root-element"/>
</start>

<define name="root-element">
ÂÂÂ <element name="root">
ÂÂÂÂÂÂÂ <ref name="items-element"/>
ÂÂÂ </element>
</define>
ÂÂÂÂÂÂÂÂ
<define name="items-content">
 <oneOrMore>
ÂÂÂ <ref name="item-element"/>
 </oneOrMore>
</define>

<define name="item-element">
ÂÂÂ <element name="item">
ÂÂÂÂÂÂÂ <attribute name="href">
ÂÂÂÂÂÂÂÂÂ <data type="anyURI">
ÂÂÂÂÂÂÂÂÂÂÂ <param name="pattern">[^\s]+.[^\s]+</param>
ÂÂÂÂÂÂÂÂÂ </data>
ÂÂÂÂÂÂÂ </attribute>ÂÂÂ
ÂÂÂÂÂÂÂ <ref name="item-content"/>
ÂÂÂ </element>
</define>

<define name="item-content">
 <empty/>
</define>

<define name="items-element">
ÂÂÂ <element name="items">
ÂÂÂÂÂÂÂ <ref name="items-content"/>
ÂÂÂ </element>
</define>
</grammar>
//sample.rng end

command line to use:
xmllint --noout --relaxng sample.rng sample.xml

On libxml2 2.7.7 I get this
sample.xml:5: element item: Relax-NG validity error : Element item failed to validate attributes
sample.xml fails to validate

On libxml2 2.7.3 I get this:
sample.xml:5: element item: Relax-NG validity error : Type anyURI doesn't allow value 'something with spaces'
sample.xml:5: element item: Relax-NG validity error : Element item failed to validate attributes
sample.xml fails to validate

Which is a desired behaviour to me.


Thanks,
--
UVCMS logo
Darko MiletiÄ
Chief Software Architect

UVCMS S.R.L.
Buenos Aires: +54 (11) 4831-0385/0389 - New York: +1 (646) 775-2914 - darko uvcms com - www.uvcms.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]