xslt - XPATH expressions and Saxon collection() function -


i'm having difficulty using collection() function in saxon. want generate text report based on xml files in directory. i've created named template, i'm passing stylesheet command line. able output text file headers, seems xpath expressions not picking individual elements.

here 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> 

here 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> 

a uri uses forward slashes change file:///c:\path\to\xml\input\files\ file:///c:/path/to/xml/input/files.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -