On 3/26/2007 9:47 AM, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to