[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2004-04-14 15:57 -0500, Uslu, Cihan Y (MED) wrote:
By building result text out of the input elements, not by building result nodes out of the input elements.
This is a request only to put out text nodes in CDATA sections, it is not a request to emit the node tree syntax inside of a CDATA section as you expected.
To get what you want you need to build your own text syntax from the input node structures and emit that as text, not as nodes.
A simple working example is below ... I hope this helps.
................. Ken
<xsl:output indent="yes" cdata-section-elements="mattext feedback"/>
</xsl:stylesheet>
T:\ftemp>saxon uslu.xml uslu.xsl
<?xml version="1.0" encoding="utf-8"?>
<tests>
<assessment teds-type="T">
<response_label>
<material>
<mattext texttype="text/html"><![CDATA[Select the<b>GPO Part Additional Info</b> link
in the <b>Navigation</b> screen]]></mattext>
</material>
</response_label>
</assessment>
<other>
<para>Select the<emphasis>GPO Part Additional Info</emphasis> link
in the <emphasis>Navigation</emphasis> screen</para>
</other>
</tests>
T:\ftemp>
Re: [xsl] CDATA question
Subject: Re: [xsl] CDATA question From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 14 Apr 2004 17:35:47 -0400 |
At 2004-04-14 15:57 -0500, Uslu, Cihan Y (MED) wrote:
I have the following XML structure, and the extract from the XSLT script which is not producing the desired output. What would be the best way to get desired output?
By building result text out of the input elements, not by building result nodes out of the input elements.
<xsl:....cdata-section-elements="mattext feedback">
This is a request only to put out text nodes in CDATA sections, it is not a request to emit the node tree syntax inside of a CDATA section as you expected.
To get what you want you need to build your own text syntax from the input node structures and emit that as text, not as nodes.
A simple working example is below ... I hope this helps.
................. Ken
T:\ftemp>type uslu.xml <tests> <assessment teds-type='T'> <distractor> <para>Select the<emphasis>GPO Part Additional Info</emphasis> link in the <emphasis>Navigation</emphasis> screen</para> </distractor> </assessment> <other> <para>Select the<emphasis>GPO Part Additional Info</emphasis> link in the <emphasis>Navigation</emphasis> screen</para> </other> </tests> T:\ftemp>type uslu.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" cdata-section-elements="mattext feedback"/>
<xsl:template match="distractor | answer"> <xsl:choose> <xsl:when test="(ancestor::assessment[@teds-type = 'M']) or (ancestor::assessment[@teds-type = 'T']) or (ancestor::assessment[@teds-type = 'U'])"> <response_label> <material> <mattext texttype="text/html"> <xsl:apply-templates mode="syntax"/> </mattext> </material> </response_label> </xsl:when> </xsl:choose> </xsl:template>
<xsl:template match="para" mode="syntax"> <xsl:apply-templates mode="syntax"/> </xsl:template>
<xsl:template match="emphasis" mode="syntax"> <xsl:text/><b><xsl:apply-templates/></b><xsl:text/> </xsl:template>
<xsl:template match="@*|node()"><!--identity for all other nodes--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
<!--this cleans up the output when using indent="yes"--> <xsl:template match="text()[not(normalize-space())]" mode="syntax"/> <xsl:template match="text()[not(normalize-space())]"/>
</xsl:stylesheet>
T:\ftemp>saxon uslu.xml uslu.xsl
<?xml version="1.0" encoding="utf-8"?>
<tests>
<assessment teds-type="T">
<response_label>
<material>
<mattext texttype="text/html"><![CDATA[Select the<b>GPO Part Additional Info</b> link
in the <b>Navigation</b> screen]]></mattext>
</material>
</response_label>
</assessment>
<other>
<para>Select the<emphasis>GPO Part Additional Info</emphasis> link
in the <emphasis>Navigation</emphasis> screen</para>
</other>
</tests>
T:\ftemp>
-- Public courses: Spring 2004 world tour of hands-on XSL instruction Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Hong Kong May 17-21; Bremen Germany May 24-28; Helsinki June 14-18
World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] CDATA question, Michael Kay | Thread | Re: [xsl] CDATA question, David Carlisle |
[xsl] CDATA question, Uslu, Cihan Y (MED) | Date | Re: [xsl] CDATA question, David Carlisle |
Month |