Subject: Re: [xsl] XML data appearing in XSL transformation From: Wendy Bossons <wbossons@xxxxxxxxxxxxxxxx> Date: Wed, 21 Jun 2006 14:37:02 -0400 (EDT) |
Per your request -- sorry, but this is pretty long ... Any help is appreciated ... here again is the issue ...
**
I am parsing some xml to output as a tree.
The transform works, but I'm also seeing the xml data in the result.
Example follows:
**
<?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"/>
<xsl:template match="/"> <html> <head> <LINK REL="stylesheet" type="text/css" href="css/tree.css"/> <SCRIPT LANGUAGE="Javascript" SRC="tree.js"></SCRIPT> <SCRIPT LANGUAGE="Javascript" SRC="../common/css.js"></SCRIPT> </head> <body> <table> <xsl:apply-templates/> </table> </body> </html> </xsl:template>
<xsl:template match="//contents">
<!-- THIS IS THE ENTITY ROW THAT WILL BE OPENED -->
<tr>
<td>
<xsl:attribute name="id">level<xsl:value-of select="parent::entity/attribute::id"/></xsl:attribute>
<xsl:choose>
<xsl:when test="parent::entity[1]/@parent = '/'">
<xsl:attribute name="STYLE">display:block; padding-left: 7px; font-family: Verdana; font-size: 11px; color: black;</xsl:attribute>
</xsl:when>
<xsl:when test="parent::entity[1]/@parent = '/e0'">
<xsl:attribute name="STYLE">display:none; padding-left: 12px; font-family: Verdana; font-size: 11px; font-color: red;</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="STYLE">display:block; padding-left: 7px; font-family: Verdana; font-size: 11px; color: black;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<table>
<xsl:for-each select="child::entity">
<xsl:call-template name="tree">
</xsl:call-template>
<xsl:apply-templates/>
</xsl:for-each>
</table>
</td>
</tr>
<!-- </xsl:for-each> -->
</xsl:template>
<xsl:template name="tree">
<xsl:variable name="imagerow"><xsl:text>imagerow</xsl:text><xsl:value-of select="@id"/><xsl:number format="1"/></xsl:variable>
<tr>
<td valign="top">
<img><!-- expand or contract from the image -->
<xsl:attribute name="id"><xsl:value-of select="$imagerow"/></xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="image"/></xsl:attribute>
<xsl:attribute name="onclick"><xsl:text>expandAndCollapseNodes('level</xsl:text><xsl:value-of select="@id"/><xsl:text>','</xsl:text><xsl:value-of select="$imagerow"/><xsl:text>');</xsl:text></xsl:attribute>
</img>
</td>
<td valign="top">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="descriptionuri"/></xsl:attribute>
<xsl:value-of select="description"/>
</xsl:element>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
**************************
XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="newtree.xsl"?>
<tree>
<entity id="e0" parent="/">
<description>Archives</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<contents>
<entity id="e00" parent="/e0">
<description>Entire Murray Holdings</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick>displayCustomer(12346)</onClick>
<contents>
<entity id="e000" parent="/e00">
<description>American Democracy</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e001" parent="/e00">
<description>Female Leadership</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e002" parent="/e00">
<description>Labor Relations</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
</contents>
</entity>
<entity id="e01" parent="/e0">
<description>ICPSR</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick>displayCustomer(12345)</onClick>
<contents>
<entity id="e010" parent="/e01">
<description>Census Enumerations</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e011" parent="/e01">
<description>Community and Urban Studies</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e012" parent="/e01">
<description>Conflict, Aggression, Violence, Wars</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
</contents>
</entity>
<entity id="e02" parent="/e0">
<description>Roper</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick>displayCustomer(12347)</onClick>
<contents>
<entity id="e020" parent="/e02">
<description>Elections</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
<contents>
<entity id="e0201" parent="/e020">
<description>CNN Poll</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/paper.gif</image>
<imageOpen>images/paper.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e0202" parent="/e020">
<description>ABC News Poll</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/paper.gif</image>
<imageOpen>images/paper.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e0203" parent="/e020">
<description>Another Folder</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
<contents>
<entity id="e02030" parent="/e020">
<description>ABC News Poll</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/paper.gif</image>
<imageOpen>images/paper.gif</imageOpen>
<onClick></onClick>
</entity>
</contents>
</entity>
</contents>
</entity>
</contents>
</entity>
<entity id="e03" parent="/e0">
<description>Census</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick>displayCustomer(12348)</onClick>
<contents>
<entity id="e030" parent="/e03">
<description>2000</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e031" parent="/e03">
<description>1990</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e032" parent="/e03">
<description>1980</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
<entity id="e033" parent="/e03">
<description>1970</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<onClick></onClick>
</entity>
</contents>
</entity>
<entity id="e04" parent="/e0">
<description>ODUM</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<contents>
<entity id="e040" parent="/e04">
<description>Public Opinion</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/paper.gif</image>
<imageOpen>images/paper.gif</imageOpen>
<contents>
</contents>
</entity>
<entity id="e041" parent="/e04">
<description>NC Vital Statistics</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/paper.gif</image>
<imageOpen>images/paper.gif</imageOpen>
<contents>
</contents>
</entity>
<entity id="e042" parent="/e04">
<description>Social Psych Data</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/paper.gif</image>
<imageOpen>images/paper.gif</imageOpen>
<contents>
</contents>
</entity>
<entity id="e043" parent="/e04">
<description>Public Opinion</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<contents>
</contents>
</entity>
<entity id="e044" parent="/e04">
<description>NC Vital Statistics</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<contents>
</contents>
</entity>
<entity id="e045" parent="/e04">
<description>Social Psych Data</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<contents>
<entity id="e046" parent="/e04">
<description>Test Group 1</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<contents>
</contents>
</entity>
<entity id="e047" parent="/e04">
<description>Test Group 2</description>
<descriptionuri>http://192.168.40.129/VDC/prototypes/collections/index.html</descriptionuri>
<oncontextmenu></oncontextmenu>
<image>images/nodeclosed.gif</image>
<imageOpen>images/nodeopen.gif</imageOpen>
<contents>
</contents>
</entity>
</contents>
</entity>
</contents>
</entity>
</contents>
</entity>
</tree>
***********************
Jagdishwar B wrote:
Hi,
************************** Any thoughts as to why this happens? I have never seen this before except when specifically asking for /* of a parent or child node.
i guess, may be u are using an <xsl:value-of select="." kind of operation when the root node is matched. then it will print concatenation of all parsed character data. but it will be difficult to tell without seeing your xsl. what xsl you are using. paste your xsl file, xml file (also if possible your expected transformed xml output).. then it would be easier to understand the situation. :)-
kind regards, Jagdishwar B.
--------------020501060901090105070603 Content-Type: text/x-vcard; charset=utf-8; name="wbossons.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="wbossons.vcf"
begin:vcard fn:Wendy Bossons n:Bossons;Wendy org:Harvard University;HMDC email;internet:wbossons@xxxxxxxxxxxxxxxx title:UI Developer tel;work:617-384-5701 tel;cell:603-759-9362 version:2.1 end:vcard
--------------020501060901090105070603--
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Can DOCTYPE survive trans, Wendell Piez | Thread | RE: [xsl] Converting CSV to XML wit, Pantvaidya, Vishwaji |
Re: [xsl] Convert XML to Excel usin, Wendell Piez | Date | RE: [xsl] XSLT arguments in PHP 5, Buchcik, Kasimier |
Month |