RE: [xsl] processing alternating sibling nodes

Subject: RE: [xsl] processing alternating sibling nodes
From: "Robert Koberg" <rob@xxxxxxxxxx>
Date: Sat, 4 Jan 2003 02:02:37 -0800
Hey Steven,

They have you working on New Years eve ? :)

How about starting with:


<xsl:template match = "/">
> > 	<html><head></head><body>
  
		<xsl:apply-templates select="home/problem"/>

> > 	</body></html>
> > 	</xsl:template>


Then you can do:


<xsl:template match="problem">
 <div class="problem">
   <xsl:apply-templates/>
 </div> 
</xsl:template>

<xsl:template match="question">
 <div class="question">
   <xsl:apply-templates/>
 </div> 
</xsl:template>

<xsl:template match="text">
 <div class="text">
   <xsl:apply-templates/>
 </div> 
</xsl:template>

<xsl:template match="reference">
 <div class="reference">
   <xsl:apply-templates/>
 </div> 
</xsl:template>


Or, simply:

<xsl:template match="*">
 <div class="name()">
   <xsl:apply-templates/>
 </div> 
</xsl:template>


best,
-Rob



> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Wright, Steve
> Sent: Tuesday, December 31, 2002 12:38 PM
> To: 'XSL-List@lists. mulberrytech. com (E-mail)'
> Subject: [xsl] processing alternating sibling nodes
> 
> 
> > ------------------------------------------------------------------------
> > I am having trouble getting the following xml tree to simply write out
> > it's contents in the order that it appears:
> > ------------------------------------------------------------------------
> > <home>
> >   <problem>
> >     <question>
> >       <text>text content 1</text>
> >       <reference>ref content 1</reference>
> >       <text>text content 2</text>
> >       <reference>ref content 2</reference>
> >       <text>text content 3</text>
> >       <reference>ref content 3</reference>
> >       <text>text content 4</text>
> >       <reference>ref content 4</reference>
> >       <text>text content 5</text>
> >     </question>
> >   </problem>
> > </home>
> > ------------------------------------------------------------------------
> > ------------------------------------------------------------------------
> > this is the most recent xsl logic that I have tried:
> > ------------------------------------------------------------------------
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!DOCTYPE home >
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> >                 xmlns:xt="http://www.jclark.com/xt";
> >                 extension-element-prefixes="xt">
> > 				
> > 	<xsl:output method="html" indent="no" encoding="ISO-8859-1"/>
> > 	
> >     <xsl:template match = "/">
> > 	<html><head></head><body>
> > 		<xsl:apply-templates/>
> > 	</body></html>
> > 	</xsl:template>
> > 	
> > 	<xsl:template match="home/problem">
> > 		<xsl:for-each select="descendant::question">		
> > 			<xsl:value-of select="text"/>
> > 			<xsl:value-of select="reference"/>
> > 		</xsl:for-each>
> > 	</xsl:template>
> > 
> > </xsl:stylesheet>
> > ------------------------------------------------------------------------
> > ------------------------------------------------------------------------
> > The output I am getting is this:
> > ------------------------------------------------------------------------
> > text content 1
> > ref content 1
> > ------------------------------------------------------------------------
> > ------------------------------------------------------------------------
> > The output I would like to get is this:
> > ------------------------------------------------------------------------
> > text content 1
> > ref content 1
> > text content 2
> > ref content 2
> > text content 3
> > ref content 3
> > text content 4
> > ref content 4
> > text content 5
> > ------------------------------------------------------------------------
> > ------------------------------------------------------------------------
> > Thanks in advance for any help you can offer.
> > -steve
> > ------------------------------------------------------------------------
> > 
> > 
> > 
> > 
> ****************************************************************************
> This email may contain confidential material.
> If you were not an intended recipient, 
> please notify the sender and delete all copies.
> We may monitor email to and from our network.
> 
> ****************************************************************************
> 
> 
> 
>  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