Last active
June 23, 2021 19:41
-
-
Save ndw/c19c21da70223773d29c0b38df3a5350 to your computer and use it in GitHub Desktop.
Return an array from a function in XSLT
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"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:array="http://www.w3.org/2005/xpath-functions/array" | |
xmlns:f="https://nwalsh.com/ns/functions" | |
xmlns:map="http://www.w3.org/2005/xpath-functions/map" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
exclude-result-prefixes="array f map xs" | |
version="3.0"> | |
<xsl:output method="xml" encoding="utf-8" indent="no"/> | |
<xsl:template match="/"> | |
<doc> | |
<xsl:sequence select="count(array:flatten(f:test()))"/> | |
</doc> | |
</xsl:template> | |
<xsl:function name="f:test" as="array(*)"> | |
<xsl:sequence select="array { (1,2,3) }"/> | |
</xsl:function> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment