1. 程式人生 > >SQL函式和XSL函式在XML Publisher中的使用

SQL函式和XSL函式在XML Publisher中的使用

       XML Publisher擴充套件了一些SQL和XSL,XSL-FO函式,使它們可以在RTF模板中使用.語法如下:

            擴充套件SQL語法:<?xdofx:expression?>

            擴充套件XSL語法:<?xdoxslt:expression?>

SQL                                 Statement Usage                           Description
2+3                                  <?xdofx:2+3?>                                 Addition
2-3                                   <?xdofx:2-3?>                                  Subtraction
2*3                                  <?xdofx:2*3?>                                   Multiplication
2/3                                   <?xdofx:2/3?>                                    Division
2**3                                <?xdofx:2**3?>                                  Exponential
3||2                                 <?xdofx:3||2?>                                   Concatenation
lpad(’aaa’,10,’.’)       <?xdofx:lpad(’aaa’,10,’.’)?>          The lpad function pads the left side of a

rpad(’aaa’,10,’.’)       <?xdofx:rpad(’aaa’,10,’.’)?>         The rpad function pads the right side of a
decode(’x’,'b’,'c’,'x’)     <?xdofx:decode(’x’,'b’,'c’,x’,'d’)?>    The decode function has the functionality of

Instr(’abcab’,'a’,2)       <?xdofx:Instr(’abca’,'a’,2)?>            The instr function returns the location of

substr(’abc’,2,3)         <?xdofx:substr(’abc’,2,3)?>              The substr function allows you to extract
replace(name,’Jo’,'J’) <?xdofx:replace(name,’Jo’,'J’)?>    The replace function replaces a sequence

to_number(’12345’)    <?xdofx:to_number(’12345’)?>
to_char(12345)           <?xdofx:to_char(12345)?>
sysdate()                      <?xdofx:sysdate()?>
minimum                    <?xdoxslt:minimum(ELEMENT_NAME)?>      Returns the minimum value of the element

maximum                   <?xdoxslt:maximum(ELEMENT_NAME)?>      Returns the maximum value of the element

Supported XSL Elements                                                     Description                                                XML Publisher 語法

<xsl:value-of select="name">                                              Placeholder syntax                                   <?name?>
<xsl:apply-templates select="name">                               Applies a template rule to the                <?apply:name?>
<xsl:copy-of select="name">                                               Creates a copy of the current node.      <?copy-of:name?>
<xsl:call-template name="name">                                    Calls a named template to be                <?call:name?>
<xsl:sort select="name">                                                     Sorts a group of data based on             <?sort:name?>
<xsl:for-each select="name">                                             Loops through the rows of data             <?for-each:name?>
<xsl:choose>                                                                          Used in conjunction with when              <?choose?>
<xsl:when test="exp">                                                           Used in conjunction with                         <?when:expression?>

<xsl:otherwise>                                                                      Used in conjunction with                         <?otherwise?>
<xsl:if test="exp">                                                                   Used for conditional formatting.             <?if:expression?>
<xsl:template name="name">                                             Template declaration                               <?template:name?>
<xsl:variable name="name">                                               Local or global variable declaration      <?variable:name?>
<xsl:import href="url">                                                           Import the contents of one                       <?import:url?>
<xsl:include href="url">                                                         Include one stylesheet in another          <?include:url?>
<xsl:stylesheet xmlns:x="url">                                             Define the root element of a stylesheet<?namespace:x=url?>

FO Element                                                                              XML Publisher 語法
<fo:page-number-citation ref-id="id">                               <?fo:page-number-citation:id?>                                   

<fo:page-number>                                                               <?fo:page-number?>
<fo:ANY NAME WITHOUT ATTRIBUTE>                          <?fo:ANY NAME WITHOUT ATTRIBUTE?>