This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
namespace output problem
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] namespace output problem
- From: "James Carlyle" <james dot carlyle at calaba dot com>
- Date: Mon, 5 Nov 2001 14:04:25 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi
I need to output xml to the textarea of an HTML form, using an XSLT
stylesheet, so that I can validate the content of an XML updategram being
posted to SQL Server. The format of the updategram (the part in the
textarea, bounded by <ROOT>) must match exactly. My stylesheet needs to
ouput the following:
<?xml version="1.0" encoding="utf-8"?>
<body>
<form action="http://oak/xml" method="POST">
<input type="hidden" name="contenttype" value="text/xml" />
<textarea rows="30" cols="100" name="template">
<ROOT xmlns:updg="urn:schemas-microsoft-com:xml-updategram">
<updg:sync>
<updg:before>
</updg:before>
<updg:after>
<testData itemLink="http://www.abc.com/1" itemTitle="weblog"/>
</updg:after>
</updg:sync>
</ROOT>
</textarea>
<input type="submit" />
</form>
</body>
My input document looks like:
<?xml version="1.0" encoding="utf-8"?>
<rss>
<channel>
<item>
<link>http://www.abc.com/1</link>
<title>weblog</title>
<description>about scripting and stuff like that.</description>
</item>
</channel>
</rss>
My stylesheet currently looks like:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:updg="urn:schemas-microsoft-com:xml-updategram"
exclude-result-prefixes="updg">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<html>
<body>
<form action="http://oak/xml" method="POST">
<input type="hidden" name="contenttype" value="text/xml"/>
<textarea rows="30" cols="100" name="template">
<ROOT>
<xsl:apply-templates select="//item"/>
</ROOT>
</textarea>
<input type="submit"/>
</form>
</body>
</html>
</xsl:template>
<!-- process item-->
<xsl:template match="item">
<updg:sync>
<updg:before>
</updg:before>
<updg:after>
<testData>
<xsl:attribute name="itemLink"><xsl:value-of
select="link"/></xsl:attribute>
<xsl:attribute name="itemTitle"><xsl:value-of
select="title"/></xsl:attribute>
</testData>
</updg:after>
</updg:sync>
</xsl:template>
</xsl:stylesheet>
I can get the namespace declaration to appear on the updg:sync element, but
not on the ROOT element, unless I add a updg:ROOT prefix to it (this breaks
SQL Server).
I've been through the FAQ looking for a solution, but can find none. Is
there a way of outputting what I want, while treating xsl:output by
method="xml"?
TIA
James Carlyle
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list