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

Transform some attributes into HTML span elements with

Subject: Transform some attributes into HTML span elements with delimiters (specific format)
From: Philipp Kursawe <phil.kursawe@xxxxxxxxx>
Date: Thu, 27 May 2010 09:28:58 +0200
 Transform some attributes into HTML span elements with
Hello,

I have this XML

<InspectionReportInput
 city="Some"
 firstName="Jon"
 lastName="Doe
 ...
 >
</InspectionReportInput>

and would like to get this (partial) HTML output:
<span id="firstName">Jon</span> <span id="lastName">Doe</span>, <span
id="city">Some</span>

So I want to put a space delimited between firstName and lastName and
after lastName a ",".
Currently my XSLT looks like this:

<xsl:call-template name="span"><xsl:with-param name="id"
select="//@firstName"></xsl:with-param></xsl:call-template>
      <xsl:call-template name="span"><xsl:with-param name="id"
select="//@lastName"></xsl:with-param></xsl:call-template>,
      <xsl:call-template name="span"><xsl:with-param name="id"
select="//@city"></xsl:with-param></xsl:call-template>

<xsl:template name="span" match="attribute::node()">
    <xsl:param name="id"></xsl:param>
    <xsl:element name="span"><xsl:attribute name="id"><xsl:value-of
select="name($id)"/></xsl:attribute><xsl:value-of
select="$id"/></xsl:element>
  </xsl:template>

As you can see its very verbose. I would like to have it a little less
verbose if possible. Something like this:
spans for the following "//@firstname //@lastName, //@city"
So I already give the charachters that should be emitted after the
template "span" is called.

Thanks!
Phil

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.