XSLT Transformation failed

Bug #1811503 reported by Anil Prasad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Won't Fix
Undecided
Unassigned

Bug Description

Hi Team,

I have one xslt and this is validated and well form and not any issue in oxygen editor or saxon parser for transformation or any kind of operation but i have use this xslt in through lxml and try to transform our file through xslt function i have get e below error:

Traceback (most recent call last):
  File "C:\Anil\PTest\TEST\test.py", line 5, in <module>
    transform = ET.XSLT(xslt)
  File "src\lxml\xslt.pxi", line 410, in lxml.etree.XSLT.__init__
lxml.etree.XSLTParseError: XSLT-variable: Failed to compile the XPath expression ''January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December''.

Kindly check and suggest how to resolve this issue.

Below is version report:
Python : sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
lxml.etree : (4, 2, 5, 0)
libxml used : (2, 9, 5)
libxml compiled : (2, 9, 5)
libxslt used : (1, 1, 30)
libxslt compiled : (1, 1, 30)

Thanks & Regards,
Anil Prasad

Revision history for this message
scoder (scoder) wrote :

Well, that doesn't look like an XPath expression to me. Could you copy&paste the relevant part of your XSLT sxript? You are using XSLT 1.0, right?

Revision history for this message
Anil Prasad (anilkumarg4) wrote :
Download full text (4.1 KiB)

No i am using xslt 2.0 and below is my code of that part:

<xsl:template match="date">
      <xsl:choose>
         <xsl:when test="parent::leg:assentdate|parent::leg:enactdate and contains(.,'; ')">
            <xsl:variable name="month"
                          select="'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'"/>
            <xsl:variable name="DATE" select="tokenize(.,' ')"/>
            <xsl:choose>
               <xsl:when test="not(@*)">
                  <xsl:analyze-string select="."
                                      regex="([0-9]+)\s+([a-zA-Z]+)\s+([0-9]+);\s+([0-9]+)\s+([a-zA-Z]+)\s+([0-9]+)">
                     <xsl:matching-substring>
                        <xsl:element name="date">
                           <xsl:variable name="DAY" select="number($DATE[1])"/>
                           <xsl:attribute name="day" select="format-number($DAY, '00')"/>
                           <xsl:attribute name="month" select="format-number(index-of($month,$DATE[2]),'00')"/>
                           <xsl:attribute name="year" select="replace($DATE[3],';','')"/>
                           <xsl:value-of select="substring-before(.,'; ')"/>
                        </xsl:element>
                        <xsl:element name="date">
                           <xsl:variable name="DAY" select="number($DATE[4])"/>
                           <xsl:attribute name="day" select="format-number($DAY, '00')"/>
                           <xsl:attribute name="month" select="format-number(index-of($month,$DATE[5]),'00')"/>
                           <xsl:attribute name="year" select="$DATE[6]"/>
                           <xsl:value-of select="substring-after(.,'; ')"/>
                        </xsl:element>
                     </xsl:matching-substring>
                     <xsl:non-matching-substring/>
                  </xsl:analyze-string>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:apply-templates select="@* | node()"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:when>
         <xsl:otherwise>
            <xsl:element name="{name()}"><!--Old code: <xsl:apply-templates select="@* | node()"/>-->
               <xsl:choose>
                  <xsl:when test="parent::pubdate">
                     <xsl:apply-templates select="@* | node()"/>
                  </xsl:when>
                  <xsl:when test="parent::leg:assentdate|parent::leg:enactdate">
                     <xsl:variable name="month"
                                   select="'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'"/>
                     <xsl:variable name="DATE" select="tokenize(normalize-space(.),' ')"/>
                     <xsl:choose>
                        <xsl:when test="not(@*)">
                           <xsl:analyze-string select="." regex="([0-9]+)\s+([a-zA-Z]+)\s+([0-9]+)">
                              <xsl:matching-substring>
                                 <xsl:variable name="DAY" select="number($DATE[1])"/>
                                 <xsl:attribute n...

Read more...

Revision history for this message
scoder (scoder) wrote :

libxslt does not implement XSLT 2.0.

Changed in lxml:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.