Project

Profile

Help

Bug #3242 » bug.instance-of-document-node.xsl

Nick Nunes, 2017-06-01 02:52

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:j="http://www.w3.org/2005/xpath-functions"
xmlns:atom="http://www.w3.org/2005/Atom"
version="3.0"
exclude-result-prefixes="#all">
<xsl:template name="main">
<xsl:variable name="atype"
as="item()*"
select="'foo'"/>
<xsl:variable name="output">
<xsl:for-each select="($atype)[1]">
<xsl:choose>
<xsl:when test="(. instance of element()) or (. instance of document-node())">
<xsl:variable name="ns-cleaned" as="item()*">
<xsl:copy-of select="." copy-namespaces="no"/>
</xsl:variable>
<xsl:sequence select="serialize($ns-cleaned)"/>
</xsl:when>
<xsl:when test="exists(.)">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:if test="exists($output)">
<xsl:sequence select="$output"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
(2-2/2)