[xsl] Typing Variable as AnyURI - Problem

Subject: [xsl] Typing Variable as AnyURI - Problem
From: Ihe Onwuka <ihe.onwuka@xxxxxxxxxxxxxx>
Date: Thu, 13 Sep 2012 07:14:07 +0100
This stylesheet is supposed to construct an HTTP call.

If I type the variable VMSCall as anyURI I get

net.sf.saxon.trans.XPathException: A sequence of more than one item is
not allowed as the value of variable $VMScall

With the casting in the call to the document function (and an untyped
variable) it works however if the variable is typed (despite casting
to anyURI) it still yields the above error.

If the call to the document function is cast as xs:string I get
net.sf.saxon.trans.XPathException: Exception thrown by URIResolver

My expectation is that if I type the variable as anyURI it should work
without the need to cast the document call. AAMOF I also expected the
call to work without having to type the variable or cast the document
function call.



Stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    xmlns:oc="http://extend.com/opencase/2.0";
        version="2.0">
    <xsl:output indent="yes" omit-xml-declaration="yes"/>
    <xsl:template match="/">
       <xsl:variable name="VMScall" ><xsl:apply-templates/></xsl:variable>
       <xsl:value-of select="document(xs:anyURI($VMScall))"/>
    </xsl:template>
    <xsl:template match="feed">
       <xsl:text>http://blah?entityType=VOD&amp;filters=beid:equals:[</xsl:text>
       <xsl:apply-templates select="product"/>]
    </xsl:template>
    <xsl:template match="product">
       <xsl:apply-templates select="descendant::oc:bundle/externalID"/>
       <xsl:if test="not(position()=last())">,</xsl:if>
    </xsl:template>
</xsl:stylesheet>


Cutdown XML

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:media="http://search.yahoo.com/mrss/";
      xmlns:oc="http://extend.com/opencase/2.0";
      xmlns:ocmedia="http://extend.com/opencase/2.0/ocmedia";>

   <product>

            <oc:bundle>
               <name>VoD_70</name>
               <altCode/>
               <uuid>4c219204-4bd9-42d9-8b39-9bd7f2b43a93</uuid>
               <externalID>Asset_0097_VoD_70</externalID>

               <createDate>2012-08-17T14:48:47.863Z</createDate>
               <lastModified>2012-08-17T14:51:16.237Z</lastModified>
               <isActive>true</isActive>
            </oc:bundle>
</product>
<product>
            <oc:bundle>
               <name>VoD_150</name>
               <altCode/>
               <uuid>7a93f556-cf0c-4761-8642-f5013b83b03f</uuid>
               <externalID>Asset_0177_VoD_150</externalID>

               <createDate>2012-08-17T14:48:59.820Z</createDate>
               <lastModified>2012-08-17T14:51:17.127Z</lastModified>
               <isActive>true</isActive>
            </oc:bundle>
</product>
</feed>

Current Thread