Created
August 23, 2013 13:41
-
-
Save rdeltour/6319457 to your computer and use it in GitHub Desktop.
XProc step to produce a sequence of `c:result` documents from a tokenized string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <p:declare-step type="px:tokenize" xmlns:p="http://www.w3.org/ns/xproc" | |
| xmlns:c="http://www.w3.org/ns/xproc-step" xmlns:px="http://www.daisy.org/ns/pipeline/xproc" | |
| version="1.0"> | |
| <p:option name="string" required="true"/> | |
| <p:option name="regex" required="true"/> | |
| <p:option name="flags" select="''"/> | |
| <p:output port="result" sequence="true"> | |
| <p:pipe port="secondary" step="tokenize-xslt"/> | |
| </p:output> | |
| <p:xslt template-name="tokenize" name="tokenize-xslt"> | |
| <p:input port="source"> | |
| <p:empty/> | |
| </p:input> | |
| <p:with-param name="string" select="$string"/> | |
| <p:with-param name="regex" select="$regex"/> | |
| <p:with-param name="flags" select="$flags"/> | |
| <p:input port="stylesheet"> | |
| <p:inline> | |
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" | |
| exclude-result-prefixes="#all"> | |
| <xsl:param name="string" as="xs:string"/> | |
| <xsl:param name="regex" as="xs:string"/> | |
| <xsl:param name="flags" as="xs:string"/> | |
| <xsl:template name="tokenize"> | |
| <xsl:for-each select="tokenize($string,$regex,$flags)"> | |
| <xsl:variable name="uri" select="resolve-uri(concat('result-',position()))"/> | |
| <xsl:result-document href="{$uri}"> | |
| <c:result><xsl:value-of select="."/></c:result> | |
| </xsl:result-document> | |
| </xsl:for-each> | |
| </xsl:template> | |
| </xsl:stylesheet> | |
| </p:inline> | |
| </p:input> | |
| </p:xslt> | |
| <p:sink/> | |
| </p:declare-step> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment