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

Re: How do i get a name-value pair in HTML output

Subject: Re: How do i get a name-value pair in HTML output
From: Eric van der Vlist <vdv@xxxxxxxxxxxx>
Date: Tue, 23 Jan 2001 10:30:54 +0100
html name value pair
Hi,

"Opstvedt, Hermod" wrote:
> 
> 
> I want to be able to do this without refering to the names of the nodes or
> attributes, because I want it to be generic.
> I can easily get out the values in the output, but how do I get the
> name/value pairing I have shown.

If you don't want to adapt any text node, 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:template match="/">
  <html>
   <head>some header</head>
   <body>
    <xsl:apply-templates/>
   </body>
  </html>
 </xsl:template>

 <xsl:template match="*">
  <xsl:text>&#x0a;</xsl:text>
  <xsl:value-of select="substring('..............', 1,
count(ancestor::*))"/>
  <xsl:value-of select="name()"/>
  <xsl:apply-templates select="*|@*|text()"/>
 </xsl:template>

 <xsl:template match="@*">
  <xsl:text>&#x0a;</xsl:text>
  <xsl:value-of select="substring('..............', 1,
count(ancestor::*))"/>
  <xsl:value-of select="name()"/>
  <xsl:text>=</xsl:text>
  <xsl:value-of select="."/>
 </xsl:template>

 <xsl:template match="text()"/>

</xsl:stylesheet>

gives you

C:\Java\tests>java
-Dcom.jclark.xsl.sax.parser=org.brownell.xml.aelfred2.SAXDriv
er com.jclark.xsl.sax.Driver view.xml view.xsl
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">some
header</
head>
<body>
myroot
.value1=first
.value2=second
.value3=third
.mynode
..value1=nodefirst
..value2=nodesecond
..mynodesnode
...value1=nodesnodefirst</body>
</html>

Hopes this helps

Eric
 
> 
> Hermod Opstvedt
> Cheif Architect IT-01
> Den norske Bank
> DnB IT EK - INTER/INTRANETT
> Postboks 7100
> 5020 Bergen, Norway
> Phone : (+47) 55 21 90 64/Mob: (+47) 957 40041 (OBS Nytt)
> EMail: hermod.opstvedt@xxxxxx
> WWW: http://www.dnb.no
-- 
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
------------------------------------------------------------------------

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


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.