[xsl] doc() concat expression and whitespace error

Subject: [xsl] doc() concat expression and whitespace error
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Mon, 15 Nov 2004 20:16:19 -0500
I'm working on pulling in -- using the doc() function -- documents from the eXist XML DB via it's http interface.

Here's my template:

<xsl:template match="db:bibliography" mode="create-bibcollection">
<bibliography>
<modsCollection xmlns="http://www.loc.gov/mods/v3";>
<xsl:for-each select="distinct-values(key('citekey', 'all'))">
<!--+ ================================================
| bibrecord variable identifies where to locate the bib records; in
| this case, we access them via http from an eXist XML DB
+-->
<xsl:variable name="bibrecord"
select='doc(concat("http://localhost:8080/exist/servlet/db/mods? _query=", "/mods:modsCollection/mods:mods[@ID='", ., "']"))'/>
<xsl:copy-of select="$bibrecord" />
</xsl:for-each>
</modsCollection>
</bibliography>
</xsl:template>


However, when I run it from Saxon, I get this error:

Error reported by XML parser: Whitespace required before attributes.

So, I decided to try to access a document via a web browser. I got an error until I added the namespace declaration in the query. So, this works from the browser:

http://localhost:8080/exist/servlet/db/biblio? _query=declare%20namespace%20mods=%22http://www.loc.gov/mods/v3%22;/ mods:modsCollection/mods:mods[@ID='Tilly2000a']

.... but this does not from Saxon:

<xsl:variable name="bibrecord"
select='doc(concat("http://localhost:8080/exist/servlet/db/biblio? _query=declare%20namespace%20mods=%22http://www.loc.gov/mods/v3%22;";, "/mods:modsCollection/mods:mods[@ID='", ., "']"))'/>


I know in theory it should work, since I got the suggestion from the author of eXist; am just not sure where the problem is. Is there something wrong with my variable select expression (which is what the error is being reported about) from the XSLT/Saxon side?

Bruce

Current Thread