|
[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
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>
</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>
</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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








