Subject: [xsl] Batch transformations From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> Date: Sat, 22 Mar 2008 09:37:08 +0000 |
>>>>> "Colin" == Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> writes: Aaron> To allow groups of files to be translated. Colin> But this can be done within a transformation using Colin> collection and xsl:result-document. To illustrate. The following transformation, if invoked as: gestalt --template=initial batch.xsl does the following: For every file in the current working directory that contains the characters .xsl as part of its filename, it writes another files with the name changed to end in .out. The contents of each such file is the single element document, containing a text node of the document URi of the original file. But any other transformation can be coded just by changing the contents of the xsl:result-document element. <?xml version="1.0" encoding="utf-8"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gexslt="http://www.gobosoft.com/eiffel/gobo/gexslt/extension" exclude-result-prefixes="gexslt xs" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template name="initial"> <xsl:variable name="col" as="node()*"> <xsl:sequence select="collection()"/> </xsl:variable> <doc> <xsl:choose> <xsl:when test="system-property ('gexslt:standard-file-collection') eq 'yes'"> <xsl:for-each select="$col"> <xsl:choose> <xsl:when test="gexslt:file/@xml:base[contains(.,'.xsl')]"> <xsl:apply-templates mode="batch" select="doc(.)"/> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:value-of>Standard file: collection is not available</xsl:value-of> </xsl:otherwise> </xsl:choose> </doc> </xsl:template> <xsl:template mode="batch" match="/"> <xsl:variable name="doc-uri" select="document-uri(.)" as="xs:string"/> <xsl:variable name="out" select="concat(substring-before($doc-uri, 'xsl'), 'out')" as="xs:string"/> <xsl:result-document href="{$out}"> <document> <xsl:value-of select="$doc-uri"/> </document> </xsl:result-document> </xsl:template> </xsl:transform> -- Colin Adams Preston Lancashire
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT processor for Mac OS, Colin Paul Adams | Thread | Re: [xsl] XSLT processor for Mac OS, James Fuller |
Re: [xsl] XSLT processor for Mac OS, Colin Paul Adams | Date | Re: [xsl] XSLT processor for Mac OS, James Fuller |
Month |