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

Is this the best way to emit one line per occurrence o

Subject: Is this the best way to emit one line per occurrence of an xpath?
From: "Karr, David" <david.karr@xxxxxxxx>
Date: Thu, 8 Nov 2007 14:12:42 -0800
 Is this the best way to emit one line per occurrence o
I had to write a simple stylesheet that prints out in text form one line
of text for every occurrence of a particular xpath in an input xml file.
I think I got it working, but I just wanted to ask for a critique of
this, to see if there are different ways of doing this.

The following is what I have so far:
--------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:output method="xml" omit-xml-declaration="yes"/>

  <xsl:template match="/">
    <xsl:apply-templates
select="/beans/bean[@singleton!='false']/@class"/>
  </xsl:template>

  <xsl:template match="@class">
    <xsl:value-of select="normalize-space(.)"/><xsl:text>
</xsl:text>
  </xsl:template>

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

This produces output like this:

--------------------------
org.apache.commons.chain.impl.ChainBase
com.wamu.stuff.Gork
com.wamu.foo.Bar
com.wamu.uia.framework.AdapterController
com.wamu.uia.adapter.HttpClientAdapter
--------------------------

Again, this is exactly what I want, I was just wondering about
alternatives for doing the same thing.

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-2011 All Rights Reserved.