[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Displaying a combination of text and child nodes

Subject: Displaying a combination of text and child nodes
From: "Karen Dunstall" <kdunstall@xxxxxxxxxxxxxxx>
Date: Tue, 8 Jul 2003 09:16:07 +1000
xsl for each child
I'm having trouble listing a combination of text and child nodes via xsl.

My xml is generated automatically by a program called Doxygen.  This section is a program listing.  No matter what I do, I can't seem to get the child elements of <codeline> (mostly sp's), if I want the whole text line.

The xml is (I have just pulled out a few lines):

<?xml version="1.0" encoding="UTF-8"?>
<doxygen>
<compounddef>
<codelisting>
<programlisting>
	<codeline lineno="1">
		<highlight class="preprocessor">#pragma<sp/>warning<sp/>(disable<sp/>:<sp/>4786)<sp/>//<sp/>Disable<sp/>STL<sp/>warning<sp/>spam</highlight>
	</codeline>
	<codeline lineno="2">
		<highlight class="preprocessor"/>
		<highlight class="normal"/>
	</codeline>
	<codeline lineno="3">
		<highlight class="normal"/>
		<highlight class="preprocessor">#include<sp/>&lt;iomanip&gt;</highlight>
		<highlight class="normal"/>
	</codeline>
	<codeline lineno="8">
		<highlight class="normal"/>
		<highlight class="preprocessor">#include<sp/>&quot;<ref refid="OurPrograms_8h" kindref="compound">OurPrograms.h</ref>&quot;</highlight>
		<highlight class="normal"/>
	</codeline>
	<codeline lineno="9">
		<highlight class="normal"/>
		<highlight class="preprocessor">#include<sp/>&quot;GMFSDate/GMFSDate.h&quot;</highlight>
		<highlight class="normal"/>
	</codeline>
	<codeline lineno="10">
		<highlight class="normal"/>
		<highlight class="preprocessor">#include<sp/>&quot;<ref refid="DB_Conn_8hpp" kindref="compound">SQLSVRDB/DB_Conn.hpp</ref>&quot;</highlight>
		<highlight class="normal"/>
	</codeline>
	<codeline lineno="34" refid="classOurCompany_1s0" refkind="member">
		<highlight class="normal"/>
		<highlight class="keyword">const</highlight>
		<highlight class="normal">
			<sp/>
			<ref refid="classOurCompany_1w0" kindref="member">OurCompany::ErrCode</ref>
			<sp/>
			<ref refid="classOurCompany_1s0" kindref="member">OurCompany::ERR_NONE</ref>
			<sp/>=<sp/>0;</highlight>
	</codeline>
    <codeline lineno="35" refid="classOurCompany_1s1" refkind="member">
		<highlight class="normal"/>
		<highlight class="keyword">const</highlight>
		<highlight class="normal">
			<sp/>
			<ref refid="classOurCompany_1w0" kindref="member">OurCompany::ErrCode</ref>
			<sp/>
			<ref refid="classOurCompany_1s1" kindref="member">OurCompany::ERR_BBX</ref>
			<sp/>=<sp/>1;</highlight>
	</codeline>
</programlisting>
</codelisting>
</compounddef>
</doxygen>

The xsl I am using is:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Code listing for a nominated function.  -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:template match="/">
		<html>
			<head>
				<title>A function</title>
				<link rel="stylesheet" href="doxygen.css" type="text/css"/>
			</head>
			<body>
				<table>
					<xsl:for-each select="doxygen/compounddef/programlisting/codeline">
						<tr>
							<td>
								<xsl:value-of select="@lineno"/>
							</td>
							<td>
								<xsl:for-each select="highlight">
									<span class="&lt;xsl:value-of select=&quot;@class&quot;/&gt;>
                                                  <!-- Doesn't seem to matter what I do here, I can get the whole text, ignoring sp elements, or I can get the first sp element, -->
                                                  <!-- or I can get the first text element only, depending on what I do  -->
                                                  <!-- I have tried xsl:for-each loops, I've tried matching templates, but I still can't seem to get it to work.  -->
										<xsl:for-each select="text()">
											<xsl:value-of select="."/>
										</xsl:for-each>
									</span>
								</xsl:for-each>
							</td>
						</tr>
					</xsl:for-each>
				</table>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>


Can anyone tell me how I can access each child element, and still get all of the text?

As you can probably see from the question, I wouldn't call myself an experienced xsl user yet.

Many thanks
Karen

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.