You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Brian K Bonner <br...@paraware.com> on 2004/05/05 18:09:56 UTC
how to eliminate xsi namespace after transformation
I'm not convinced that there is anything wrong per se, but after
performing my transformation, I'm finding that the namespace is being
included in each of my result elements. If I eliminate the xmlns:xsi and
the xsi:schemaLocation from the source file, I get the expected result
xmlfile, but I don't believe the original source can be validated. I'm
asking this here since I'm using xalan-j. I'm not sure if this is an
Xalan-j, XSL, or XMLSchema question.
I've included a test case below:
SOURCE XMLFILE
==============
<?xml version="1.0" encoding="ISO-8859-1"?>
<order:form xmlns="http://www.w3.org/1999/xhtml"
xmlns:order="http://www.paraware.com/order"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.paraware.com/order order.xsd">
<b>Ordered By</b>
<br/>
<order:author/>
<br/>
<order:subject/>
<br/>
<order:sendTo values="test@yahoo.com" userDefined="false"/>
<br/>
<order:timestamp/>
<br/>
</order:form>
OBTAINED RESULT XMLFILE
=======================
<?xml version="1.0" encoding="UTF-8"?>
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:order="http://www.paraware.com/order"
xmlns:xhtml="http://www.w3.org/1999/xhtml"><form>
<b xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Ordered
By</b>
<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
Author:unassigned
<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
Subject: <input name="subject" type="text"/>
<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
To: test@yahoo.com
<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
Created: unassigned
<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</form></div>
EXPECTED RESULT XMLFILE
=======================
<?xml version="1.0" encoding="UTF-8"?>
<div xmlns:order="http://www.paraware.com/order"
xmlns:xhtml="http://www.w3.org/1999/xhtml"><form>
<b>Ordered By</b>
<br/>
Author:unassigned
<br/>
Subject: <input name="subject" type="text"/>
<br/>
To: test@yahoo.com
<br/>
Created: unassigned
<br/>
</form></div>
XSLFILE
=======
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:order="http://www.paraware.com/order"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:param name="user1">unassigned</xsl:param>
<xsl:param name="current_time">unassigned</xsl:param>
<xsl:template match="order:form">
<div>
<form>
<xsl:text/>
<xsl:apply-templates/>
</form>
</div>
</xsl:template>
<xsl:template match="order:author"> Author:<xsl:value-of
select="$user1"/>
<xsl:text/>
</xsl:template>
<xsl:template match="order:sendTo">
<xsl:if test="@userDefined = 'true'">
<xsl:if test="string-length(normalize-space(@values)) = '0'">
To:<input type="text" name="sendTo"/>
<xsl:text/>
</xsl:if>
<xsl:if test="string-length(normalize-space(@values)) >
'0'">
<xsl:if
test="starts-with(substring(normalize-space(@values),
string-length(normalize-space(@values))), ',')">
To: <xsl:value-of select="@values"/>
<input type="text" name="sendTo"/>
<xsl:text/>
</xsl:if>
<xsl:if
test="not(starts-with(substring(normalize-space(@values),
string-length(normalize-space(@values))), ','))">
To: <xsl:value-of select="@values"/>, <input
type="text" name="sendTo"/>
<xsl:text/>
</xsl:if>
</xsl:if>
</xsl:if>
<xsl:if test="@userDefined = 'false'"> To: <xsl:value-of
select="@values"/>
<xsl:text/>
</xsl:if>
</xsl:template>
<xsl:template match="order:subject"> Subject: <input type="text"
name="subject"/>
<xsl:text/>
</xsl:template>
<xsl:template match="order:timestamp"> Created: <xsl:value-of
select="$current_time"/>
<xsl:text/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Thanks,
- Brian
Re: how to eliminate xsi namespace after transformation
Posted by Joseph Kesselman <ke...@us.ibm.com>.
I believe you're looking for the xsl:exclude-result-prefixes attribute of
the xsl:stylesheet element.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk