 |
| 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
|
|
|
|

November 7th, 2007, 09:12 AM
|
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
wml transform
am trying to transform an xml file to wml using asp.net. I get the xml file from sql server as a string. so I need to convert it to xml and tranform that xml file to wml.
Here is my code:
private void XmlTransformToWML(string hn_xml)
{
XmlDocument xpathDoc = new XmlDocument();
xpathDoc.LoadXml(hn_xml);
string xslPath = Server.MapPath("hnxml.xslt");
XslCompiledTransform myXslTrans = new XslCompiledTransform();
//Load the XSL stylsheet into the XslCompiledTransform object
myXslTrans.Load(xslPath);
myXslTrans.Transform(xmlDoc, null, Response.Output);
}
My problem is when I execute this code I am getting the following exception. I have a doubt, can we use XmlDocument as a argument to transform to wml.
Exception:
System.Xml.Xsl.XslTransformException: Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added
Please help me!!
Thanks
Aruna.G
|
|

November 7th, 2007, 09:24 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
There is an error in your XSLT file.
Without wanting to seem like I'm just repeating your post, "Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node".
I suggest you check your stylesheet, and make sure you are not using the <xsl:attribute> instruction incorrectly (or possibly a <xsl:apply-templates select="@*"/>)
If you still cannot work out the problem then show us your stylesheet.
/- Sam Judson : Wrox Technical Editor -/
|
|

November 7th, 2007, 09:36 AM
|
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi
Thanks you very much for your reply. Actually its working and giving the wml result if I use "XslTransform" instead of "XslCompiledTransform".
Here is my code for XslTransform:
XmlDocument xpathDoc = new XmlDocument();
xpathDoc.LoadXml(hn_xml);
string xslPath = Server.MapPath("hnxml.xslt");
XslTransform transform = new XslTransform();
transform.Load(xslPath);
XmlDocument wmlDoc = new XmlDocument();
wmlDoc.Load(transform.Transform(xpathDoc.DocumentE lement.CreateNavigator(), null));
Response.ContentType = "text/vnd.wap.wml";
Response.Write("<?xml version='1.0'?>");
Response.Write("<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.3//EN' 'http://www.wapforum.org/DTD/wml13.dtd'>");
Response.Write(wmlDoc.InnerXml);
If the problem is with my xslt then it should not work with this code. Is it still my xslt problem? If not, anyone please tell me.
The reason that why I was not using this code is: when I use this my emulator is showing two times <?xml version="1.0"?> and the <wml> tags. I thought thats becoz I was using xmldocument to load into response. Could anyone please tell me how to get rid of this problem.
Here is output that I am getting if I use the second code:
<?xml version='1.0'?><!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.3//EN' 'http://www.wapforum.org/DTD/wml13.dtd'><wml><card id="toc" title="WML Topic"><p><b>3.3 Reflecting Verbal Cross References</b><br />&nbsp;Verbal cross references like "See also Chapter 4, Preserves Graphics" are published by first removing page references and then by adding an actual hyperlink to the document containing the referenced topic. The next sentence is another example. For more information on preservation of graphics, refer to Graphics.Hyperlink references in the publication are maintained and updated, as appropriate, when the source document is revised and re-published.Some examplesLink 1:For more information see (Topic "Introduction" in "Microsoft Solution for Intranets/Prescriptive Architecture Guide").Link 2:refer to (Topic "Implementation Considerations" in "Content Management and SPS whitepaper") done.Link 3:See also (Topic "Summary" in "Capacity Planning for Microsoft SharePoint Portal Server 2001") done.Link 4:See also (Topic "Introduction" in "Building a Corporate Portal using Microsoft Office XP and Microsoft SharePoint Portal Server 2001") done.Link 5:See also (Topic âScenario 1: Intranet Site with Comprehensive Searchâ in âContent Management and SPS whitepaperâ)</p></card></wml><?xml version='1.0'?>
<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN' 'http://www.wapforum.org/DTD/wml_1.1.xml'><wml><head>
<meta http-equiv="Cache-Control" content="max-age=0" />
</head>
<card>
<do type="prev" label="Back"><prev /></do>
<p></p></card>
</wml>
Thanks,
Aruna.G
Quote:
quote:Originally posted by samjudson
There is an error in your XSLT file.
Without wanting to seem like I'm just repeating your post, "Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node".
I suggest you check your stylesheet, and make sure you are not using the <xsl:attribute> instruction incorrectly (or possibly a <xsl:apply-templates select="@*"/>)
If you still cannot work out the problem then show us your stylesheet.
/- Sam Judson : Wrox Technical Editor -/
|
|
|

November 7th, 2007, 09:48 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Well, I still think the error is in your XSLT code, but I'm not sure, as you didn't list it.
You can avoid the output of the second XML declaration by using wmdDoc.DocumentElement.OuterXml I think.
/- Sam Judson : Wrox Technical Editor -/
|
|

November 7th, 2007, 09:52 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
It's always slightly surprising when two different XSLT processors give different results on the same code, but one can't investigate the problem without seeing the code.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

November 7th, 2007, 09:59 AM
|
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
Here is my code which gives two <?xml version="1.0"?> and <wml>
public partial class topic : System.Web.UI.MobileControls.MobilePage
{
protected void Page_Load(object sender, EventArgs e)
{
string doxtopDbConn = "Server=doxtop01; Database=HNHDS; User Id=hnadmin;password=password";
SqlConnection sqlConn = new SqlConnection(doxtopDbConn);
if (!IsPostBack)
{
string topicId = Request.QueryString.Get("tid");
string query = String.Format("SELECT [HNXML] FROM [HNHDS].[dbo].[HDS_TOPIC] WHERE [DOC_UNID]='{0}'",topicId);
System.Data.SqlClient.SqlCommand sqlCommand = new System.Data.SqlClient.SqlCommand(query,sqlConn);
try
{
if (sqlConn.State == ConnectionState.Closed)
{
sqlConn.Open();
}
SqlDataReader result = sqlCommand.ExecuteReader();
if (result.Read())
{
string hnxml = result["HNXML"].ToString();
//Response.Write(hnxml);
XmlTransformToWML(hnxml);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
}
private void XmlTransformToWML(string hn_xml)
{
XmlDocument xpathDoc = new XmlDocument();
xpathDoc.LoadXml(hn_xml);
string xslPath = Server.MapPath("hnxml.xslt");
XslTransform transform = new XslTransform();
transform.Load(xslPath);
XmlDocument wmlDoc = new XmlDocument();
wmlDoc.PreserveWhitespace = false;
wmlDoc.Load(transform.Transform(xpathDoc.DocumentE lement.CreateNavigator(), null));
Response.ContentType = "text/vnd.wap.wml";
Response.Write("<?xml version='1.0'?>");
Response.Write("<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.3//EN' 'http://www.wapforum.org/DTD/wml13.dtd'>");
Response.Write(wmlDoc.InnerXml);
}
}
Thanks
Aruna.G
|
|

November 7th, 2007, 10:01 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Michael meant your XSLT code (i.e. your stylesheet) not your C# code.
/- Sam Judson : Wrox Technical Editor -/
|
|

November 7th, 2007, 10:07 AM
|
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
My XSLT is includes 6 other xslts. Here are they:
1) hnxslt.xslt
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<!--wml>
<card id="hnxml" title="WML Topic">
<p-->
<xsl:include href="default/topic.xslt"/>
<xsl:include href="default/list.xslt"/>
<xsl:include href="default/table.xslt"/>
<xsl:include href="default/para.xslt"/>
<xsl:include href="default/paraChars.xslt"/>
<xsl:include href="default/common.xslt"/>
<!--/p>
</card>
</wml-->
</xsl:stylesheet>
2) topic.xslt
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/topic">
<wml>
<card id="toc" title="WML Topic">
<p>
<b><xsl:value-of select="@heading" /></b><br/>
<xsl:if test="content">
<xsl:apply-templates select="content"/>
</xsl:if>
</p>
</card>
</wml>
</xsl:template>
<xsl:template match="content[@id]" mode="outOfOrder">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="content[@id]"></xsl:template>
<xsl:template match="content[not(@id)]">
<xsl:choose>
<xsl:when test="/topic/@seqNum < 2">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:apply-templates select="*[not(@isFirst='1')]" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
3) list.xslt
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="list">
<xsl:apply-templates select="item"/>
</xsl:template>
<xsl:template match="item">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:apply-templates/><br/>
</xsl:template>
<xsl:template match="bullet">
<xsl:value-of select="@text"/>
</xsl:template>
</xsl:stylesheet>
4) table.xslt
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="table">
<xsl:variable name="columnCount" select="count(columns/column)"/>
<table columns="{$columnCount}">
<xsl:apply-templates select="row"/>
</table>
</xsl:template>
<xsl:template match="row">
<tr>
<xsl:apply-templates select="cell" />
</tr>
</xsl:template>
<xsl:template match="cell">
<td>
<xsl:apply-templates />
</td>
</xsl:template>
</xsl:stylesheet>
5) paraChars.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="char[@hidden='1']"></xsl:template>
<xsl:template match="char">
<xsl:variable name="styleId" select="@class" />
<xsl:if test="not(/topic/styles/style[@type='char' and @styleId=$styleId]/@hidden='1') or @hidden='0'">
<xsl:call-template name="revBegin" />
<xsl:choose>
<xsl:when test="@vAlign='super'">
<sup>
<xsl:choose>
<xsl:when test="ancestor::classification">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</sup>
</xsl:when>
<xsl:when test="@vAlign='sub'">
<sub>
<xsl:choose>
<xsl:when test="ancestor::classification">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</sub>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="style">
<xsl:apply-templates select="@*" />
</xsl:variable>
<xsl:if test="@class!=''">
<xsl:attribute name="class">
<xsl:value-of select="@class" />
</xsl:attribute>
</xsl:if>
<xsl:if test="$style!=''">
<xsl:attribute name="style">
<xsl:value-of select="$style" />
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="ancestor::classification">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
6)common.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="text()[ancestor::para | ancestor::item | ancestor::cell]">
<xsl:call-template name="textWithSpaces">
<xsl:with-param name="source" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="textWithSpaces">
<xsl:param name="source" />
<xsl:text />
<xsl:choose>
<xsl:when test="$source=' '">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="contains($source, ' ')">
<xsl:value-of select="substring-before($source, ' ')" />
<xsl:text disable-output-escaping="yes"> &nbsp;</xsl:text>
<xsl:call-template name="textWithSpaces">
<xsl:with-param name="source" select="substring-after($source, ' ')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$source" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
get-internal-link samples the internal link informations so that HyperNet is able to
- store the infos in the PUB_LINK_INFO table in HNMI
- apply link construction rules
<xsl:param name="exclude" /> : (optional) The flag indicating whether this link should not been stored in the PUB_LINK_INFO table in HNMI; valid values {'true', 'false'}
<xsl:param name="exclude" /> : (optional) The flag indicating whether this link should not been stored in the PUB_LINK_INFO table in HNMI; valid values {'true', 'false'}
<xsl:param name="xsltid" /> : The unique id (used to apply the 'hyperlink' ids (e.g.: ... id="<#assignlinkid_d {$xsltid}#>" ...))
<xsl:param name="linkhandler" /> : The link handler
<xsl:param name="param1" /> : The 1st parameter (for internal links: DOC_UNID)
<xsl:param name="param2" /> : The 2nd parameter (for internal links: additional param(s))
<xsl:param name="hash" /> : The hash
xslt output of internal href:
"<&hnlink/internal" + ["!exclude" + ]
" <" + xsltid + ">" +
" <" + hnencoded(linkhandler) + ">" +
" <" + hnencoded(param1) + ">" +
" <" + hnencoded(param2) + ">" +
" <" + hnencoded(hash) + ">" +
"&>"
e.g.:
"<&hnlink/internal <xslt5678> <link handler> <param 1> <param 2> <hash>&>"
"<&hnlink/internal!exclude <xslt5678> <> <param 1> <> <>&>"
-->
<xsl:template name="get-internal-link">
<xsl:param name="exclude" />
<xsl:param name="xsltid" />
<xsl:param name="linkhandler" />
<xsl:param name="param1" />
<xsl:param name="param2" />
<xsl:param name="hash" />
<xsl:text><#hnlink/internal</xsl:text>
<xsl:if test="$exclude = 'true'">!exclude</xsl:if>
<xsl:text> <</xsl:text>
<xsl:value-of select="$xsltid" />
<xsl:text>></xsl:text>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$linkhandler" />
</xsl:call-template>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$param1" />
</xsl:call-template>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$param2" />
</xsl:call-template>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$hash" />
</xsl:call-template>
<xsl:text disable-output-escaping="yes">#></xsl:text>
</xsl:template>
<!--
get-external-link samples the external link informations so that the HyperNet is able to
- store the infos in the PUB_LINK_INFO table in HNMI
- apply link construction rules
<xsl:param name="xsltid" /> : The unique id (used to apply the 'hyperlink' ids (e.g.: ... id="<#assignlinkid_d {$xsltid}#>" ...))
<xsl:param name="linkhandler" /> : The link handler
<xsl:param name="type"> : The link configuration type (default: "*")
<xsl:param name="encoded" /> : The flag indicating if the parameters are already encoded (default is unencoded; assing the value 'true' if parameters are encoded)
<xsl:param name="param1" /> : The 1st parameter (default rule: database)
<xsl:param name="param2" /> : The 2nd parameter (default rule: publication title)
<xsl:param name="param3" /> : The 3rd parameter (default rule: document heading)
<xsl:param name="param4" /> : The 4th parameter (default rule: additional param(s))
xslt output of external href:
"<&hnlink/external[" + type + "]" +
" <" + xsltid + ">" +
" <" + hnencoded(linkhandler) + ">" +
" <" + hnencoded(param1) + ">" +
" <" + hnencoded(param2) + ">" +
" <" + hnencoded(param3) + ">" +
" <" + hnencoded(param4) + ">" +
"&>"
e.g.:
"<&hnlink/external[*] <xslt5678> <link.aspx> <> <pub&title> <doc heading> <><>&>"
-->
<xsl:template name="get-external-link">
<xsl:param name="xsltid" />
<xsl:param name="linkhandler" />
<xsl:param name="type">*</xsl:param>
<xsl:param name="encoded" />
<xsl:param name="param1" />
<xsl:param name="param2" />
<xsl:param name="param3" />
<xsl:param name="param4" />
<xsl:text><#hnlink/external[</xsl:text>
<xsl:value-of select="$type" />
<xsl:text>]</xsl:text>
<xsl:if test="$encoded = 'true'">!encoded</xsl:if>
<xsl:text> <</xsl:text>
<xsl:value-of select="$xsltid" />
<xsl:text>></xsl:text>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$linkhandler" />
</xsl:call-template>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$param1" />
</xsl:call-template>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$param2" />
</xsl:call-template>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$param3" />
</xsl:call-template>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$param4" />
</xsl:call-template>
<xsl:text disable-output-escaping="yes">#></xsl:text>
</xsl:template>
<!--
get-outside-link samples the outside link information so that the HyperNet is able to
- store the infos in the PUB_LINK_INFO table in HNMI
<xsl:param name="xsltid" /> : The unique id (used to apply the 'hyperlink' ids (e.g.: ... id="<#assignlinkid_d {$xsltid}#>" ...))
<xsl:param name="ref" /> : The (already url encoded) reference
xslt output of outside href:
"<&hnlink/outside" +
" <" + xsltid + ">" +
" <" + hnencoded(ref) + ">" +
"&>"
e.g.:
"<&hnlink/outside <xslt5678> <http://www.acme.com/outside%20reference.html>&>"
-->
<xsl:template name="get-outside-link">
<xsl:param name="xsltid" />
<xsl:param name="ref" />
<xsl:text><#hnlink/outside</xsl:text>
<xsl:text> <</xsl:text>
<xsl:value-of select="$xsltid" />
<xsl:text>></xsl:text>
<xsl:call-template name="encode-param">
<xsl:with-param name="param" select="$ref" />
</xsl:call-template>
<xsl:text disable-output-escaping="yes">#></xsl:text>
</xsl:template>
<!--
This type supports the HyperNet infrastructure and is not intended to be used directly from your code.
-->
<xsl:template name="encode-param">
<xsl:param name="param" />
<xsl:text disable-output-escaping="yes"> <</xsl:text>
<xsl:call-template name="find-and-replace">
<xsl:with-param name="source">
<xsl:call-template name="find-and-replace">
<xsl:with-param name="source">
<xsl:call-template name="find-and-replace">
<xsl:with-param name="source" select="$param" />
<xsl:with-param name="find" select="'&'" />
<xsl:with-param name="replace" select="'&amp;'" />
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="find" select="'<'" />
<xsl:with-param name="replace" select="'&lt;'" />
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="find" select="'>'" />
<xsl:with-param name="replace" select="'&gt;'" />
</xsl:call-template>
<xsl:text disable-output-escaping="yes">></xsl:text>
</xsl:template>
<!--
This type supports the HyperNet infrastructure and is not intended to be used directly from your code.
-->
<xsl:template name="find-and-replace">
<xsl:param name="source" />
<xsl:param name="find" />
<xsl:param name="replace" />
<xsl:choose>
<xsl:when test="$find and contains($source, $find)">
<xsl:value-of select="substring-before($source, $find)" />
<xsl:value-of select="$replace" />
<xsl:call-template name="find-and-replace">
<xsl:with-param name="source" select="substring-after($source, $find)" />
<xsl:with-param name="find" select="$find" />
<xsl:with-param name="replace" select="$replace" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$source" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="newline">
<xsl:text>#13;#10;</xsl:text>
</xsl:template>
<xsl:template name="ptSum">
<xsl:param name="p1">0pt</xsl:param>
<xsl:param name="p2">0pt</xsl:param>
<xsl:variable name="n1" select="substring-before(concat($p1, 'pt'), 'pt')" />
<xsl:variable name="n2" select="substring-before(concat($p2, 'pt'), 'pt')" />
<xsl:value-of select="concat(string($n1 + $n2), 'pt')" />
</xsl:template>
<xsl:template name="ptNumber">
<xsl:param name="p" />
<xsl:choose>
<xsl:when test="contains($p, 'pt')">
<xsl:value-of select="substring-before($p, 'pt')" />
</xsl:when>
<xsl:otherwise>NaN</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="revBegin">
<xsl:if test="@revId">
<xsl:variable name="revId" select="@revId" />
<xsl:choose>
<xsl:when test="/topic/revInfos/revInfo[@id=$revId]/@type = 'insertion'">
<xsl:text disable-output-escaping="yes"><ins></xsl:text>
</xsl:when>
<xsl:when test="/topic/revInfos/revInfo[@id=$revId]/@type = 'deletion'">
<xsl:text disable-output-escaping="yes"><del></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template name="revEnd">
<xsl:if test="@revId">
<xsl:variable name="revId" select="@revId" />
<xsl:choose>
<xsl:when test="/topic/revInfos/revInfo[@id=$revId]/@type = 'insertion'">
<xsl:text disable-output-escaping="yes"></ins></xsl:text>
</xsl:when>
<xsl:when test="/topic/revInfos/revInfo[@id=$revId]/@type = 'deletion'">
<xsl:text disable-output-escaping="yes"></del></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="@paddingTop">padding-top:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@paddingRight">padding-right:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@paddingBottom">padding-bottom:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@border">border:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@borderLeft">border-left:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@borderTop">border-top:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@borderRight">border-right:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@borderBottom">border-bottom:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@charBorder">border:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@charBorderLeft">border-left:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@charBorderTop">border-top:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@charBorderRight">border-right:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@charBorderBottom">border-bottom:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@lineHeight">line-height:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@vAlign">vertical-align: '<xsl:value-of select="." />'; </xsl:template>
<xsl:template match="@align">text-align:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@fontName">font-family:'<xsl:value-of select="." />'; </xsl:template>
<xsl:template match="@fontSize">font-size:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@foregroundColor">color:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@backgroundColor">background-color:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@charBackgroundColor">background-color:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@bold[.='1']">font-weight:bold; </xsl:template>
<xsl:template match="@bold[.='0']">font-weight:normal; </xsl:template>
<xsl:template match="@italic[.='1']">font-style:italic; </xsl:template>
<xsl:template match="@italic[.='0']">font-style:normal; </xsl:template>
<xsl:template match="@underline[.='1'][../@strike='1']">text-decoration:underline line-through; </xsl:template>
<xsl:template match="@underline[.='1']">text-decoration:underline; </xsl:template>
<xsl:template match="@underline[.='0'][../@strike='1']">text-decoration:line-through; </xsl:template>
<xsl:template match="@underline[.='0']">text-decoration:none; </xsl:template>
<xsl:template match="@strike[.='1'][not(../@underline)]">text-decoration:line-through; </xsl:template>
<xsl:template match="@strike[.='0'][not(../@underline)]">text-decoration:none; </xsl:template>
<xsl:template match="@caps[.='1']">text-transform:uppercase; </xsl:template>
<xsl:template match="@caps[.='0']">text-transform:none; </xsl:template>
<xsl:template match="@smallCaps[.='1']">font-variant:small-caps; </xsl:template>
<xsl:template match="@smallCaps[.='0']">font-variant:normal; </xsl:template>
<xsl:template match="@charSpacing">letter-spacing:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@bulletFontName">font-family:'<xsl:value-of select="." />'; </xsl:template>
<xsl:template match="@bulletFontSize">font-size:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@bulletForegroundColor">color:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@bulletBackgroundColor">background-color:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@bulletBold[.='1']">font-weight:bold; </xsl:template>
<xsl:template match="@bulletBold[.='0']">font-weight:normal; </xsl:template>
<xsl:template match="@bulletItalic[.='1']">font-style:italic; </xsl:template>
<xsl:template match="@bulletItalic[.='0']">font-style:normal; </xsl:template>
<xsl:template match="@bulletUnderline[.='1'][../@bulletStrike='1']">text-decoration:underline line-through; </xsl:template>
<xsl:template match="@bulletUnderline[.='1']">text-decoration:underline; </xsl:template>
<xsl:template match="@bulletUnderline[.='0'][../@bulletStrike='1']">text-decoration:line-through; </xsl:template>
<xsl:template match="@bulletUnderline[.='0']">text-decoration:none; </xsl:template>
<xsl:template match="@bulletStrike[.='1'][not(../@bulletUnderline)]">text-decoration:line-through; </xsl:template>
<xsl:template match="@bulletStrike[.='0'][not(../@bulletUnderline)]">text-decoration:none; </xsl:template>
<xsl:template match="@width">width:<xsl:value-of select="." />; </xsl:template>
<xsl:template match="@cellSpacing">cell-spacing:<xsl:value-of select="." />; </xsl:template>
</xsl:stylesheet>
7.para.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="para[@hidden='1']"></xsl:template>
<xsl:template match="para">
<xsl:text/>
<xsl:choose>
<xsl:when test="@isEmpty='1'">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--xsl:template match="content/para">
<xsl:text/>
<xsl:choose>
<xsl:when test="@isEmpty='1'">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template-->
<xsl:template match="symbol">
<xsl:choose>
<xsl:when test="@special='br'">
<br />
</xsl:when>
<xsl:when test="@special='softBr'">
<br />
</xsl:when>
<xsl:when test="@special='tab'">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="@special='noBreakHyphen'">-</xsl:when>
<xsl:when test="@special='softHyphen'"><wbr /></xsl:when>
<xsl:when test="@hexValue and @fontName">
<xsl:text disable-output-escaping="yes">&#x</xsl:text>
<xsl:value-of select="@hexValue" />
<xsl:text>;</xsl:text>
</xsl:when>
<xsl:when test="@hexValue">
<xsl:text disable-output-escaping="yes">&#x</xsl:text>
<xsl:value-of select="@hexValue" />
<xsl:text>;</xsl:text>
</xsl:when>
<xsl:otherwise />
</xsl:choose>
</xsl:template>
<xsl:template match="link">
<xsl:apply-templates select="./bookmark[@pos='start']" mode="anchor" />
<xsl:variable name="xsltid" select="generate-id()" />
<xsl:choose>
<xsl:when test="@type='internal' and @ref=''">
<xsl:apply-templates />
</xsl:when>
<xsl:when test="@type='internal'">
<xsl:choose>
<xsl:when test="@ref=/topic/@unid">
<a class="hn_internal">
<xsl:attribute name="href">#<xsl:value-of select="@bookmark" /></xsl:attribute>
<xsl:if test="@target">
<xsl:attribute name="target">
<xsl:value-of select="@target" />
</xsl:attribute>
</xsl:if>
<xsl:if test="@screentip">
<xsl:attribute name="title">
<xsl:value-of select="@screentip" />
<
|
|

November 7th, 2007, 10:34 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Your template revBegin outputs text nodes, so this code looks highly questionable:
<xsl:if test="...">
<xsl:call-template name="revBegin" />
<xsl:choose>
<xsl:when test="@vAlign='super'">
...
</xsl:when>
<xsl:otherwise>
<xsl:variable name="style">
<xsl:apply-templates select="@*" />
</xsl:variable>
<xsl:if test="@class!=''">
<xsl:attribute name="class">
<xsl:value-of select="@class" />
</xsl:attribute>
</xsl:if>
At the very least, it looks capable of outputting an attribute node (class) after outputting the text nodes from revBegin, which is exactly what the error message says is happening.
The whole dependence of the code on disable-output-escaping is a cause for concern. This is usually a symptom that something is wrong.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

November 7th, 2007, 10:44 AM
|
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
I tried with out "disable-output-escaping" in my code. But still I am getting the same problem.
Thanks,
Aruna.F
Quote:
quote:Originally posted by mhkay
Your template revBegin outputs text nodes, so this code looks highly questionable:
<xsl:if test="...">
<xsl:call-template name="revBegin" />
<xsl:choose>
<xsl:when test="@vAlign='super'">
...
</xsl:when>
<xsl:otherwise>
<xsl:variable name="style">
<xsl:apply-templates select="@*" />
</xsl:variable>
<xsl:if test="@class!=''">
<xsl:attribute name="class">
<xsl:value-of select="@class" />
</xsl:attribute>
</xsl:if>
At the very least, it looks capable of outputting an attribute node (class) after outputting the text nodes from revBegin, which is exactly what the error message says is happening.
The whole dependence of the code on disable-output-escaping is a cause for concern. This is usually a symptom that something is wrong.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| WML and XSL transformation. |
Feodorov |
XSLT |
2 |
February 13th, 2008 05:00 PM |
| aspx for wml |
arunagottimukkala |
ASP.NET 1.0 and 1.1 Professional |
0 |
October 26th, 2007 05:35 AM |
| aspx with wml |
arunagottimukkala |
ASP.NET 1.x and 2.0 Application Design |
0 |
October 25th, 2007 09:39 AM |
| WML and WAP help |
knight |
Classic ASP XML |
1 |
February 28th, 2005 07:59 AM |
| where is wml.jar |
mask95 |
All Other Wrox Books |
1 |
August 19th, 2004 09:17 PM |
|
 |