previous  next

Querying External Parameters

An issue that has come up recently is Querying an XQuery text to display a list of external variables and their types.

This is easy to achieve with xq2xml:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="xq2xq.xsl"/>

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:for-each select="//Prolog/VarDecl[External]">
      <xsl:variable name="t">
	<xsl:apply-templates select="TypeDeclaration/SequenceType"/>
      </xsl:variable>
      <xsl:value-of select="'&#10;Name =',QName,'  Type =',normalize-space($t)"/>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>