Home > Software engineering >  How can use xsl tag in xml?
How can use xsl tag in xml?

Time:10-22

HelloAll,

I want to use <xsl:variable name="vPageNumber"><fo:page-number /></xsl:variable> in below code but editor give me a response such as javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; The prefix "xsl" for element "xsl:variable" is not bound. What can i do?

<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:static-content flow-name="page-header">
    <fo:table border="solid">
        <fo:table-column column-width="20%"/>
        <fo:table-column column-width="67%"/>
        <fo:table-column column-width="13%"/>
        <fo:table-body>
            <fo:table-row >
            <fo:table-cell>
                   <fo:block padding-right="15px" padding-bottom="2mm" padding-top="1mm">
                         <fo:block text-align="right" margin-right="24px"   > 
                            <fo:external-graphic content-width="20mm"  src="url(D:/Atlassian/images/Turkak.gif)" />
                         </fo:block>
                       <fo:table width="20mm" height="24mm" font-size="7pt" >
                             <fo:table-row border="solid" height="8mm">
                                  <fo:table-cell>
                                      <fo:block text-align="center" padding="3mm" > 
                                          AB-1365-T
                                      </fo:block>
                                  </fo:table-cell>
                             </fo:table-row>
                             <fo:table-row border="solid" height="8mm" >
                                 <fo:table-cell>
                                      <fo:block text-align="center" padding="3mm">$xmlutils.escape($issue.key)</fo:block>
                                 </fo:table-cell>
                             </fo:table-row>
                             <fo:table-row border="solid" height="8mm" >
                                 <fo:table-cell>
                                      <fo:block text-align="center" padding="3mm"> $date.format("MM-yy", $issue.getCustomFieldValue("customfield_17843"))</fo:block>
                                 </fo:table-cell>
                             </fo:table-row>
                        </fo:table-body>
                      </fo:table>
                  </fo:block>
                </fo:table-cell>
                </fo:table-row>
        </fo:table-body>
    </fo:table>
</fo:static-content>

CodePudding user response:

You can't use information unknown in the XSL stage. A page number is only known during the composition phase not the transformation to XSL FO.

You can only look to composing to the FO processors intermediate format and then applying a new transformation to it to use the data.

In your example you do not give any information as to why you need it as a variable. If you only want it printed then you should just use fo:page-number.

CodePudding user response:

if you define

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" font-family="auto">

you can use xsl tag in code.

  • Related