previous  next

Direct element constructor

XQuery to generate an element with name elem:

<elem>.....</elem>

An identical XSLT literal result element and would do essentially the same operation.

However xq2xsl generates:

<xsl:element name="elem">
  <xsl:variable name="content" as="item()*">.....</xsl:variable>
  <xsl:variable name="att"
                select="$content[. instance of attribute()]/node-name(.)"/>
  <xsl:if test="count($att)!=count(distinct-values($att))">
    <xsl:sequence select="error(QName('http://www.w3.org/2005/xqt-errors',
                                      'XQDY0025'),
                                'duplicated attribute')"/>
  </xsl:if>
  <xsl:sequence select="$content"/>
</xsl:element name="elem"/>