AH Formatter / XSL Formatter
Q&A



XSLT/XSL-FO/SVG/MathML Conformance

XSLT

Top
Basic, General
About AH Formatter
About XSL Formatter
Operation
Programming
XSLT/XSL-FO/SVG/MathML Conformance
XSLT/XSL-FO/MathML Technics
Index
Q.  Is it possible to embed the date of formatting to the formatted output? [No.2003013105]
A. 

It's possible by using script in a stylesheet. (Note: As it's an extensional function of XSLT, it depends on XSTL processor you use.)

<xsl:stylesheet version="1.0"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:user="urn:my-scripts"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <!-- msxsl:script get date -->
    <msxsl:script language="JScript" implements-prefix="user">
        function date(nodelist) {
            var DateObj = new Date()
            return DateObj.getFullYear() + "yy" +
                    (DateObj.getMonth() +1 )+ "mm" +
                        DateObj.getDate() + "dd";
        }
    </msxsl:script>

-----syncopation----

    <!-Output creation date -->
    <fo:block text-align="right">
        Creation date<xsl:value-of select="user:date()"/>
    </fo:block>

If you use the XSL Formatter Java interface, this way (use of msxsl:script and JScript) might often cause the error. The JNI(JavaNativeInterface) technology is used in the Java interface. However, we examined the occurrence of the error in the above-mentioned part when MSXML and JNI were used. The error seems to happen when a lot of XML is converted into XSL-FO. We recommend other ways of the use of xsl:param or the use of external XSLT processor and the enhanced feature, etc. to the output at the date.


Copyright © 1999-2011 Antenna House, Inc. All rights reserved.
Antenna House is a trademark of Antenna House, Inc.