Transformation XSL



我对XSL有一些问题。

  1. 我有以下XSL文件

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>

但是,有可能知道转换何时正确完成吗?

  1. 可以将XSL与数据库连接吗?,因为我必须将转换的结果保存在数据库中

(1)如果您查看用于从Java调用Saxon的API(JAXP API或s9api API),您将看到所有相关方法都定义了异常。如果转换失败,将抛出其中一个异常。您还可以通过指定ErrorListener在错误发生时接收错误通知来获得有关错误的更详细信息。

(2) 将转换结果放入数据库是Java代码的责任。如果您希望次要结果文档(即xsl:result-document的输出)进入数据库,Saxon允许您指定一个OutputURIResolver,当每个结果文档可用时将调用它。

最新更新