Subject: Re: [xsl] 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 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How do i get a name-value pai, Opstvedt, Hermod | Thread | RE: [xsl] How do i get a name-value, Michael Kay |
[xsl] Environment Information, Handren Mokri | Date | [xsl] sorting by date, Aedemar Cooke |
Month |