Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2005, 04:18 PM
Registered User
 
Join Date: Oct 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I remove xmlns from transformed document?

I'm working on transforming an xml file into something I can use in tiles. I seem to have hit a wall.

Here is my xml:
<?xml version="1.0" encoding="UTF-8"?>

<page>
<header>test</header>
</page>

Here is my xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet exclude-result-prefixes="tiles xalan java xsl" version="1.0"
xmlnsalan="http://xml.apache.org/xalan"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns:tiles="/WEB-INF/struts-tiles.tld"
xmlns:java="http://xml.apache.org/xslt/java">

<xsl:output omit-xml-declaration="yes" indent="yes" method="html" media-type="text/html" standalone="yes"/>

<xsl:template match="/" >
<tiles:insert>
<xsl:attribute name="definition">2col</xsl:attribute>
<xsl:attribute name="flush">true</xsl:attribute>


<xsl:apply-templates select="page" />

</tiles:insert>
</xsl:template>


<xsl:template match="page">
<tilesut name="mainBody">
<h1>
<xsl:value-of select="header" />
</h1>

</tilesut>
</xsl:template>

</xsl:stylesheet>

Here is the result:

<tiles:insert definition="2col" flush="true" xmlns:tiles="/WEB-INF/struts-tiles.tld">
<tilesut name="mainBody"><h1>test</h1>
</tilesut>
</tiles:insert>

I would expect:
<tiles:insert definition="2col" flush="true">
<tilesut name="mainBody"><h1>test</h1>
</tilesut>
</tiles:insert>

Any ideas on how to remove xmlns:tiles="/WEB-INF/struts-tiles.tld"?


 
Old October 27th, 2005, 03:31 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your desired output is not well-formed XML: it contains a namespace prefix "tiles" that has not been declared. XSLT never creates ill-formed XML, if you really want this you will need a different tool.

Why have you declared the output method as HTML when you are not generating HTML?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 27th, 2005, 08:20 AM
Registered User
 
Join Date: Oct 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,

I'm trying to generate jsp tiles (think struts/tiles). I think I'm going to try doing this using jsp's xml syntax. That might help clear up my problems.

Thanks for the reply.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Item Missing in Transformed Document raohara XSLT 2 July 27th, 2006 12:09 AM
xmlns albusr .NET Web Services 0 December 24th, 2005 08:25 AM
Adding XSLT transformed XML content dynamically jacob ASP.NET 1.x and 2.0 Application Design 2 December 1st, 2005 04:40 PM
Add XSLT transformed XML (html) on an aspx page humour XSLT 2 September 30th, 2004 05:13 AM
Add and Remove Nodes in XML document. tutul128 XML 3 March 1st, 2004 10:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.