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

RE: Need to output an opening or closing tag by itself

Subject: RE: Need to output an opening or closing tag by itself
From: "Hofman, Peter" <peter.hofman@xxxxxxxxxx>
Date: Wed, 25 Jun 2008 09:32:40 +0200
RE:  Need to output an opening or closing tag by itself
Hi David,

has been shown before on this list.
Have a look at the following thread:
http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/20
0401/msg00694.html

The selection you need in a template that handles e[@t='a'] looks like
this:

following-sibling::*[generate-id(preceding-sibling::e[1]) =
generate-id(current()) and following-sibling::e[1]/@t='b']

But that is just one approach.
You may also want to skip processing of e[@t='b'].

I suggest you dive into the xsl-list archive...

Cheers,
Peter

>-----Original Message-----
>From: David Frey [mailto:dpfrey@xxxxxxx]
>Sent: woensdag 25 juni 2008 6:30
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject:  Need to output an opening or closing tag by itself
>
>I have a simple XSLT problem for the gurus.
>
>
>This is my input document:
><root>
>  <e t="a"/>
>  <f/>
>  <f/>
>  <e t="b"/>
></root>
>
>
>This is the output document I want to produce:
><root>
>  <e>
>    <f/>
>    <f/>
>  </e>
></root>
>
>
>This is the stylesheet I wrote to do the transformation:
><?xml version="1.0" encoding="UTF-8"?>
><xsl:stylesheet
>  version="1.0"
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>  <xsl:template match="/root">
>    <root>
>      <xsl:apply-templates/>
>    </root>
>  </xsl:template>
>
>  <xsl:template match="e">
>    <xsl:choose>
>      <xsl:when test="@t ='a'">
>        <e>
>      </xsl:when>
>      <xsl:when test="@t ='b'">
>        </e>
>      </xsl:when>
>      <xsl:otherwise>
>        <xsl:message terminate="yes">
>          Unexpected data in attribute t.
>        </xsl:message>
>      </xsl:otherwise>
>    </xsl:choose>
>  </xsl:template>
>
>  <xsl:template match="f">
>    <xsl:copy/>
>  </xsl:template>
></xsl:stylesheet>
>
>
>Here is the Saxon output:
>$ java -jar "c:\Program Files\Saxon\saxon9.jar" -o out.xml
>in.xml test.xslt Error on line 16 column 9 of
>file:/C:/Documents%20and%20Settings/DFREY/Desktop/test/test.xslt:
>  SXXP0003: Error reported by XML parser: The element type "e"
>must be terminated by the
>  matching end-tag "</e>".
>Failed to compile stylesheet. 1 error detected.
>
>
>I understand that the source of the error is that the XSLT
>file is not valid XML because the <e> tag doesn't have a
>matching </e> tag in the right place.
>
>How can I work around this issue to solve my problem?
>
>Thanks,
>David
>
>
>

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an intended
recipient then please promptly delete this e-mail and any attachment and all
copies and inform the sender. Thank you.

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.