2016-11-10 4 views
0

私はSaxonでcollection()関数を使用するのに問題があります。私はディレクトリ内のすべてのXMLファイルに基づいてテキストレポートを生成したい。名前付きテンプレートを作成しました。これをコマンドラインからスタイルシートに渡します。ヘッダー付きのテキストファイルを出力することはできますが、XPATH式は個々の要素を取り上げていないようです。ここでXPath式とSaxon collection()関数

はXMLである:ここでは

<?xml version='1.0'?> 
<document form='Submission'> 
    <item name='FiscalYear'><text>2012</text></item> 
    <item name='RequestType'><text>General</text></item> 
    <item name='LeadMinistry'><text>Ministry of Truth</text></item> 
    <item name='MinRef'><text>67890</text></item> 
    <item name='LogNo'><text>12345</text></item> 
    <item name='Division'><text>IFSB</text></item> 
    <item name='Branch'><text>MEI</text></item> 
</document> 

はXSLTです:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="text" omit-xml-declaration="yes" indent="no"/> 
    <xsl:variable name="newline"> 
     <xsl:text> 
</xsl:text> 
    </xsl:variable> 
    <xsl:param name="input-dir" select="'file:///C:\path\to\XML\input\files\'"/> 
    <xsl:template name="main"> 
     <xsl:variable name="input-docs" select="collection(iri-to-uri(concat($input-dir, '?select=*.xml')))"/> 
     <xsl:value-of select="'LogNo|MinRef|FiscalYear|RequestType|Division|Branch|LeadMinistry'"/> 
     <xsl:value-of select="$newline"/> 
     <xsl:for-each select="$input-docs/document[@form = 'Submission']"> 
      <xsl:value-of select="concat(item[@name = 'LogNo']/text, '| ')"/> 
      <xsl:value-of select="concat(item[@name = 'MinRef']/text, '| ')"/> 
      <xsl:value-of select="concat(item[@name = 'FiscalYear']/text, '| ')"/> 
      <xsl:value-of select="concat(item[@name = 'RequestType']/text, '| ')"/> 
      <xsl:value-of select="concat(item[@name = 'Division']/text, '| ')"/> 
      <xsl:value-of select="concat(item[@name = 'Branch']/text, '| ')"/> 
      <xsl:value-of select="concat(item[@name = 'LeadMinistry']/text, '| ')"/> 
      <xsl:value-of select="$newline"/> 
     </xsl:for-each> 
    </xsl:template> 
</xsl:stylesheet> 

答えて

0

URIは、すべての前方がそうfile:///C:/path/to/XML/input/filesfile:///C:\path\to\XML\input\files\を変更スラッシュ使用しています。

+0

スラッシュをスラッシュに変更しましたが、それでも機能しません。私はスラッシュが問題ではないと思っています。私は実際にこのXSLTを、私が数年前に書いたのと同じようなものに基づいていました。 – b00kgrrl

+0

ディレクトリパスにエラーがありますが、スラッシュが混在していることを指摘してくれてありがとうございます。 – b00kgrrl