Re: [xslt] Error on identity transform



Well you are not seeing the issue because I mistakenly wrote that the error occurred when calling xsltParseStylesheetFile when the error actually occurs in xsltApplyStylesheet.  The problem occurs when I call the Options template from within the DesignModel template after already outputting the Options node.  The Options template then is to basically output all attributes unless one of the more specific templates match and specifically do not copy the attribute to the result as these have been phased out.  I have included the relevant xsl, input xml, and a snippet of what the result used to look like.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     version="1.0">

   <xsl:variable name="Modified">false</xsl:variable>
   <xsl:variable name="no_button">NoButton</xsl:variable>
   <xsl:variable name="newline">
     <xsl:text>

 </xsl:text>
   </xsl:variable>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*" />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="DesignModel">
    <DesignModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
      <xsl:value-of select="$newline" />

      <Pages>
        <xsl:value-of select="$newline" />
        <xsl:apply-templates select="Pages/SurveyPageModel" />
        <xsl:value-of select="$newline" />
      </Pages>

      <xsl:value-of select="$newline" />

      <Options>
        <xsl:value-of select="$newline" />
        <xsl:apply-templates select="Options" />
      </Options>
      <xsl:value-of select="$newline" />
    </DesignModel>

  </xsl:template>
.
.
.

<!-- Need to remove the button text attributes from the options xml -->

  <xsl:template match="Options">
    <xsl:apply-templates select="node()|@*"/>
  </xsl:template>

  <xsl:template match="//DesignModel/Options/@NextPageButtonText">
  </xsl:template>

  <xsl:template match="//DesignModel/Options/@FinalPageButtonText">
  </xsl:template>

</xsl:stylesheet>

----------------------------------------------------------
A very much stripped down version of the input xml file looks like the following:

<DesignModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <Pages>
    <SurveyPageModel Title="Page 1" DocumentId="26">
      <Items>
      </Items>
    </SurveyPageModel>
  </Pages>
  <Options FinalPageOption="NoButtons" FinalPageRedirectUrl="" ProgressBarVisible="false" ProgressBackColorDone="AAAAAA" 
ProgressBackColorCurrent="000000" ProgressBackColorRemainder="FFFFFF" ProgressBorderColor="000000" NextPageButtonText="Next" 
FinalPageButtonText="Submit">
    <FinalActions/>
  </Options>
</DesignModel>

----------------------------------------------------------

This is what the options xml should end up looking like. Notice, the NextPageButonText and FinalPageButtonText have been removed.  This worked with the old libraries but causes the error mentioned before with the current ones.

<Options FinalPageOption=\"NoButtons\" FinalPageRedirectUrl=\"\" ProgressBarVisible=\"false\" ProgressBackColorDone=\"AAAAAA\" ProgressBackColorCurrent=\"000000\" ProgressBackColorRemainder=\"FFFFFF\" ProgressBorderColor=\"000000\">\n\n    <FinalActions/>\n  </Options>



-----Original Message-----
From: xslt-bounces gnome org [mailto:xslt-bounces gnome org] On Behalf Of William M. Brack
Sent: Saturday, December 15, 2007 12:05 PM
To: The Gnome XSLT library mailing-list
Subject: Re: [xslt] Error on identity transform

Schubert, Aaron wrote:
> I am testing an upgrade of libxml/libxslt with the following versions:
>
> -        XML_LIBS     = /libxml/2.6.23/lib/libxml2.a
> +        XML_LIBS     = /libxml/2.6.30/lib/libxml2.a
>
> -        XSLT_LIBS    = /libxslt/1.1.15/lib/libxslt.a
> +        XSLT_LIBS    =/libxslt/1.1.22/lib/libxslt.a
>
> C code that calls xsltParseStylesheetFile is spitting out the following
> error:
>
> runtime error: file /........../upgrade.xsl line 15 element copy
> Attribute nodes must be added before any child nodes to an element.
>
> This appears to be complaining about the identity transform.  See below.
>
> That xsl file has the following lines at the start of the file:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>     version="1.0">
>
>   <xsl:variable name="Modified">false</xsl:variable>
>   <xsl:variable name="no_button">NoButton</xsl:variable>
>   <xsl:variable name="newline">
>     <xsl:text>
>
> </xsl:text>
>   </xsl:variable>
>
>   <xsl:template match="node()|@*">
>     <xsl:copy>
>       <xsl:apply-templates select="node()|@*" />
>     </xsl:copy>
>   </xsl:template>
>
> .
> .
> .
>
> I also tried the following:
>   <xsl:template match="@*|node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@*|node()" />
>     </xsl:copy>
>   </xsl:template>
>
> One example on the web stated that I should add the following after
> <xsl:copy>
>
> <xsl:copy-of select="@*"/>
>
> Didn't work.
>
> I'm assuming this must be some environment issue.  Any ideas?
>
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt gnome org

I don't see the problem you're reporting:

[bill bbxp work]$ xsltproc --version
Using libxml 20630, libxslt 10122 and libexslt 813
xsltproc was compiled against libxml 20629, libxslt 10122 and libexslt 813
libxslt 10122 was compiled against libxml 20629
libexslt 813 was compiled against libxml 20629
[bill bbxp work]$ xsltproc bug.xsl bug.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
  <xsl:variable name="Modified">false</xsl:variable>
  <xsl:variable name="no_button">NoButton</xsl:variable>
  <xsl:variable name="newline">
    <xsl:text>

    </xsl:text>
  </xsl:variable>
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
[bill bbxp work]$


Bill

_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt gnome org
http://mail.gnome.org/mailman/listinfo/xslt


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