[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] XML from JSP


Subject: [xsl] XML from JSP
From: Gavin Myers <gavinm@xxxxxxxxx>
Date: Fri, 15 Nov 2002 14:29:54 -0600

I have to include an xml file, like this:
[XML name=text.xml]
<?xml version="1.0"?>
<text>
	<block ID="1">this</block>
	<block ID="1">is</block>
	<block ID="1">a</block>
	<block ID="4">test</block>
	<block ID="5">work!</block>
</text>
[/XML]

[XSL]
<xsl:key name="block" match="/text/block" use="@ID"/>
<xsl:for-each select="document('text.xml')">
  <xsl:for-each select="key('block', '1')">
    <xsl:value-of select="."/>
  </xsl:for-each>
</xsl:for-each>
[/XSL]

This works fine. I can rename it from text.xml to text.jsp and it will still
work. But, once I try to add jsp commands in it will break. Something as
simple as this:

[JSP name=text.jsp]
<?xml version="1.0"?>
<%
String block = "work";
%>
<text>
	<block ID="1">this</block>
	<block ID="1">is</block>
	<block ID="1"><%=block%></block>
	<block ID="4">test</block>
	<block ID="5">work!</block>
</text>
[/JSP]

The JSP will compile fine and output just like the XML did, but I get the
following error: Can not load requested doc: The markup in the document
preceding the root element must be well-formed.

I'm assuming it is taking the JSP and not compiling it (treating it as is).
Is this true? Is there anything I can do to work around this?

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xml