Re: [xsl] attributes and elements

Subject: Re: [xsl] attributes and elements
From: "Bruce D'Arcus" <bdarcus@xxxxxxxxxxx>
Date: Fri, 5 Dec 2003 18:51:16 -0500
J.Pietschmann wrote:

Bruce D'Arcus wrote:
                <content>
--->                    <xsl:if test="*/condition">
--->                        <xsl:apply-templates/>
--->                    </xsl:if>


The test test, whether one of the child elements of the section element has a condicion element as child. I just can't quite match the XSLT with your problem spec, as a rather wild guess I'd say try: ... <content> <xsl:apply-templates mode="filter-condition"/> ...

  <xsl:template match="*[@condition='screen']"
     mode="filter-condition">
     <xsl:apply-templates/>
  </xsl:template>

<xsl:template match="node()" mode="filter-condition"/>

I've put together a stripped down example. Let's say here's my instance:


<section>
<title>title</title>
<p>Some text to become <q type="screen">a bullet</q> here.</p>
</section>

I just want output like:

<h1>title</h1>
<content>
	<bullet>a bullet</bullet>
</content>

I can't seem to get that. Here's the xslt, using your example:

----------------------
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method='xml' version='1.0' encoding='utf-8' indent='yes'/>


<xsl:template match="section">
	<h1>
		<xsl:apply-templates select="title"/>
	</h1>
    <content>
      <xsl:apply-templates mode="filter-condition"/>
	</content>
</xsl:template>

<xsl:template match="*[@type='screen']" mode="filter-condition">
     <bullet>
		<xsl:apply-templates/>
	</bullet>
</xsl:template>

<xsl:template match="node()" mode="filter-condition"/>

</xsl:stylesheet>
------------------------
Bruce


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



Current Thread