You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Christofer.Dutz@univativ.de" <ch...@univativ.de> on 2007/03/26 16:47:13 UTC
Transform the output of the ValidationReportTransformers in XSL
Hi,
I am having a problem that is totally driving me nuts (Cocoon 2.1.10):
I am using the ValidationReportTransformer to create a report why a validation of an xml-document failed.
I nicely outputs a report with a nice little xmlns attribute ... this is driving me nuts:
<?xml version="1.0" encoding="ISO-8859-1"?>
<report xmlns="http://apache.org/cocoon/validation/1.0">
<error line="11">cvc-minLength-valid: Value 'Dutz' with length = '4' is not facet-valid with
respect to minLength '6' for type '#AnonType_namekontaktladeraumangebot'.</error>
<error line="11">cvc-type.3.1.3: The value 'Dutz' of element 'name' is not valid.</error>
<error line="24">cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect
to minLength '1' for type '#AnonType_plzfreiladeraumangebot'.</error>
<error line="24">cvc-type.3.1.3: The value '' of element 'plz' is not valid.</error>
<error line="25">cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect
to minLength '1' for type '#AnonType_ortfreiladeraumangebot'.</error>
<error line="25">cvc-type.3.1.3: The value '' of element 'ort' is not valid.</error>
<error line="26">cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect
to minLength '1' for type '#AnonType_landfreiladeraumangebot'.</error>
<error line="26">cvc-type.3.1.3: The value '' of element 'land' is not valid.</error>
<error line="36">cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'.</error>
<error line="36">cvc-type.3.1.3: The value '' of element 'fahrzeugtyp' is not valid.</error>
</report>
As soon as this xmlns-attribute is there no XSL transformation seems to work. For example: If I simply want to replace the root element "report" with a "test" element, this xsl should do the job:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns="http://apache.org/cocoon/validation/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/report">
<test>
<xsl:copy-of select="error"/>
</test>
</xsl:template>
</xsl:stylesheet>
Unfortunetly the "/report" doesn't match and the pure text is copied to the output.
If I change it to "
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns="http://apache.org/cocoon/validation/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<test>
<xsl:copy-of select="error"/>
</test>
</xsl:template>
</xsl:stylesheet>
At least the test is copied.
The only transformation that works is:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns="http://apache.org/cocoon/validation/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/*">
<test>
<xsl:copy-of select="*"/>
</test>
</xsl:template>
</xsl:stylesheet>
Could someone tell me why this is that way and how I can convince the validation-report transformer to stop adding the namespace stuff to the output?
Well at the moment I got everything to work, by modifying the Transformers code, but that can't really be the optimal solution.
Regards,
Christofer Dutz
[ c h r i s t o f e r d u t z ]
IT-Berater
univativ GmbH & Co. KG
Robert-Bosch-Str. 7, 64293 Darmstadt
fon: 0 61 51 / 66 717 - 21
fax: 0 61 51 / 66 717 - 29
email: christofer.dutz@univativ.de <ma...@univativ.de>
http://www.univativ.de
Darmstadt, Stuttgart, Karlsruhe, Düsseldorf, München
Re: Transform the output of the ValidationReportTransformers in XSL
Posted by Lars Huttar <la...@sil.org>.
On 3/26/2007 9:47 AM, Christofer.Dutz@univativ.de wrote:
> Hi,
>
>
>
> I am having a problem that is totally driving me nuts (Cocoon 2.1.10):
>
> I am using the ValidationReportTransformer to create a report why a validation of an xml-document failed.
>
> I nicely outputs a report with a nice little xmlns attribute ... this is driving me nuts:
>
>
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <report xmlns="http://apache.org/cocoon/validation/1.0">
>
> <error line="11">cvc-minLength-valid: Value 'Dutz' with length = '4' is not facet-valid with
>
> respect to minLength '6' for type '#AnonType_namekontaktladeraumangebot'.</error>
>
> <error line="11">cvc-type.3.1.3: The value 'Dutz' of element 'name' is not valid.</error>
>
> <error line="24">cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect
>
> to minLength '1' for type '#AnonType_plzfreiladeraumangebot'.</error>
>
> <error line="24">cvc-type.3.1.3: The value '' of element 'plz' is not valid.</error>
>
> <error line="25">cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect
>
> to minLength '1' for type '#AnonType_ortfreiladeraumangebot'.</error>
>
> <error line="25">cvc-type.3.1.3: The value '' of element 'ort' is not valid.</error>
>
> <error line="26">cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect
>
> to minLength '1' for type '#AnonType_landfreiladeraumangebot'.</error>
>
> <error line="26">cvc-type.3.1.3: The value '' of element 'land' is not valid.</error>
>
> <error line="36">cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'.</error>
>
> <error line="36">cvc-type.3.1.3: The value '' of element 'fahrzeugtyp' is not valid.</error>
>
> </report>
>
>
>
> As soon as this xmlns-attribute is there no XSL transformation seems to work. For example: If I simply want to replace the root element "report" with a "test" element, this xsl should do the job:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xsl:stylesheet xmlns="http://apache.org/cocoon/validation/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
>
> <xsl:template match="/report">
>
> <test>
>
> <xsl:copy-of select="error"/>
>
> </test>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> Unfortunetly the "/report" doesn't match and the pure text is copied to the output.
>
>
That's right, it shouldn't. The default namespace in the stylesheet only
applies to unprefixed elements in the stylesheet, such as <test>... not
XPath expressions, like /report. See
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e1012
> If I change it to "
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xsl:stylesheet xmlns="http://apache.org/cocoon/validation/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
>
> <xsl:template match="/">
>
> <test>
>
> <xsl:copy-of select="error"/>
>
> </test>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> At least the test is copied.
>
>
The <test> is output, but no <error> elements will be copied because
there is no <error> child of the context node (/).
> The only transformation that works is:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xsl:stylesheet xmlns="http://apache.org/cocoon/validation/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
>
> <xsl:template match="/*">
>
> <test>
>
> <xsl:copy-of select="*"/>
>
> </test>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> Could someone tell me why this is that way and how I can convince the validation-report transformer to stop adding the namespace stuff to the output?
>
See http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e1012
You want
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:v="http://apache.org/cocoon/validation/1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/v:report">
<v:test>
<xsl:copy-of select="v:error"/>
</v:test>
</xsl:template>
</xsl:stylesheet>
Lars
> Well at the moment I got everything to work, by modifying the Transformers code, but that can't really be the optimal solution.
>
>
>
> Regards,
>
>
>
> Christofer Dutz
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Transform the output of the ValidationReportTransformers in XSL
Posted by Reinhard Poetz <re...@apache.org>.
Christofer.Dutz@univativ.de wrote:
[snip]
> Could someone tell me why this is that way
I think that the match rules apply to empty namespaces and not the default
namespace.
> and how I can convince the validation-report transformer to stop adding the namespace stuff to the output?
>
> Well at the moment I got everything to work, by modifying the Transformers code, but that can't really be the optimal solution.
this might help, though haven't tested it:
<xsl:stylesheet xmlns:v="http://apache.org/cocoon/validation/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/v:report">
<test>
<xsl:copy-of select="v:error"/>
</test>
</xsl:template>
</xsl:stylesheet>
--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}
web(log): http://www.poetz.cc
--------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org