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

RE: RE: Insert html tag between elements

Subject: RE: RE: Insert html tag between elements
From: "Jason Macki" <jmacki@xxxxxxx>
Date: Wed, 10 Jul 2002 14:30:38 -0500
xsl insert tag
Hi Astor,

If I understand what you're trying to do, you want the following:

This template matches the "body" element.  For each paragraph element
under "body", it copies the element's contents (including any
subelements), and inserts a <br /> tag in between.  The if element was
included to prevent the <br /> tag from showing up after the last
paragraph.  If you want a <br /> there, just remove the if element.

<xsl:template match="body">
	<xsl:for-each select="paragraph/node()">
		<xsl:copy-of select="." />
		<xsl:if test="position() != last()">
			<br />
		</xsl:if>
	</xsl:for-each>
</xsl:template>

Then in your main template, call the template that matches "body".  Your
main template should always have "/" for the match, because this matches
the root of the XML document.

<xsl:template match="/">
	<xsl:apply-templates select="Root/page/body" />
</xsl:template>

- Jason

-----Original Message-----
From: Astor Rivera [mailto:arivera@xxxxxxxx] 
Sent: Wednesday, July 10, 2002 1:38 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject:  RE: Insert html tag between elements


Hello,

I'd like to know or get some hints as to how to
insert an html tag in between elements.
<=== XML page ===>
<Root>
	<page>
		<body>
			<paragraph> Sentence goes here.</paragraph>
			<paragraph> Sentence goes here.</paragraph>
		<body>
	</page>
</Root>

<=== XSL page ===>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
	<xsl:output method="html"/>
	<!-- ========== Produce HTML ========== -->
	<xsl:template match="pagination ">
		<html>
			<head>
				<title>ESRI Map Book, Volume 17</title>
			</head>
			<body topmargin="0" marginheight="0"
leftmargin="0" marginwidth="0">
				<xsl:apply-templates
select="//body/paragraph"/>
			</body>
		</html>
	</xsl:template>
</xsl:transform>

All I end up getting is all of the paragraphs in one giant block. I
would like to insert a <br /> or a <p> tag in between.

Any assistance would be greatly appreciated.

Thanks,
Astor

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


 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.