简体   繁体   中英

Transformation XSL

I have some questions with XSL.

  1. I have the following XSL file.

XSLT 2.0

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template name="main" match="/">
        <xsl:for-each select="collection('file:///C:/Users/Quality/Documents/ProyectoComerciales/download_files/?select=*.txt;unparsed=yes')">
            <xsl:variable name="file" select="tokenize(document-uri(.), '/')[last()]"/>
            <xsl:variable name="name" select="substring-before($file,'.')"/>
            <xsl:variable name="url" select="concat('file:///C:/Users/Quality/Documents/ProyectoComerciales/xml/',$name,'.xml')"/>
            <xsl:result-document method="xml" indent="yes" href="{$url}">
                <xsl:variable name="path" select="concat('file:///C:/Users/Quality/Documents/ProyectoComerciales/download_files/',$file)"/>
                <xsl:variable name="text" select="tokenize(unparsed-text($path),'&#xD;&#xA;')"/>
                <download>
                    ...
                </download>
            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

But is possible to know when the transformation finished correctly?

  1. Is possible connect XSL with a data base?, because I have to save the result of the transformation in my data base

(1) If you look at the API for calling Saxon from Java (either the JAXP API or the s9api API) you will see that all the relevant methods have exceptions defined. If the transformation fails, one of these exceptions will be thrown. You can also get more detailed information about the errors by nominating an ErrorListener to receive notification of errors as they occur.

(2) Getting the transformation result into a database is the responsibility of your Java code. If you want the secondary result documents (that is, the output of xsl:result-document) to go into a database, Saxon allows you to nominate an OutputURIResolver which will be called when each result document is available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM