|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Problem with modified "Pretty XML Tree Viewer "(by Mik
Hi,
I modified (more precise: stripped down) the "Pretty XML Tree Viewer 1.0" from Mike J. Brown and Jeni Tennison for my needs. Now I have two questions: 1. Here my modified tree-view.xsl: <?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" indent="no"/> <xsl:variable name="apos">'</xsl:variable> <xsl:template match="/"> <html> <head> <title>Supertable</title> <style type="text/css"> body { font-family: sans-serif; font-size: 80%; background-color: #EAEAD9; color: black } .connector { font-family: monospace; } .name { color: navy; background-color: white; text-decoration: underline; font-weight: bold; padding-top: 0px; padding-bottom: 1px; padding-left: 3px; padding-right: 3px } .altname { color: navy; text-decoration: underline } .uri { color: #444; font-style: italic } .value { color: #040; background-color: #CCC; font-weight: bold } .escape { color: #620; font-family: monospace } .root { color: yellow; background-color: black } .element { color: yellow; background-color: navy } .namespace { color: yellow; background-color: #333 } .attribute { color: yellow; background-color: #040 } .text { color: yellow; background-color: #400 } .pi { color: yellow; background-color: #044 } .comment { color: yellow; background-color: #303 } .root,.element,.attribute,.namespace,.text,.comment,.pi { font-weight: bold; padding-top: 0px; padding-bottom: 1px; padding-left: 3px; padding-right: 3px } </style> </head> <body> <h3>tree-view.xsl output</h3> <xsl:apply-templates select="." mode="render"/> </body> </html> </xsl:template> <xsl:template match="/" mode="render"> <span class="root">root</span> <br/> <xsl:apply-templates mode="render"/> </xsl:template> <xsl:template match="*" mode="render"> <xsl:call-template name="ascii-art-hierarchy"/> <br/> <xsl:call-template name="ascii-art-hierarchy"/> <span class="connector">___</span> <span class="element">Tabelle</span> <xsl:text> </xsl:text> <span class="name"> <xsl:value-of select="local-name()"/> </span> <br/> <xsl:apply-templates select="@*" mode="render"/> <xsl:apply-templates mode="render"/> </xsl:template> <xsl:template match="@*" mode="render"> <xsl:call-template name="ascii-art-hierarchy"/> <span class="connector">  </span> <span class="connector">\___</span> <span class="attribute">attribute</span> <xsl:text> </xsl:text> <span class="name"> <xsl:value-of select="local-name()"/> </span> <xsl:text> = </xsl:text> <span class="value"> <!-- make spaces be non-breaking spaces, since this is HTML --> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="translate(.,' ',' ')"/> </xsl:call-template> </span> <br/> </xsl:template> <xsl:template match="processing-instruction()" mode="render"> <xsl:call-template name="ascii-art-hierarchy"/> <br/> <xsl:call-template name="ascii-art-hierarchy"/> <span class="connector">___</span> <span class="pi">processing instruction</span> <xsl:text> </xsl:text> <xsl:text>target=</xsl:text> <span class="value"> <xsl:value-of select="name()"/> </span> <xsl:text> instruction=</xsl:text> <span class="value"> <xsl:value-of select="."/> </span> <br/> </xsl:template> <xsl:template name="ascii-art-hierarchy"> <xsl:for-each select="ancestor::*"> <xsl:choose> <xsl:when test="following-sibling::node()"> <span class="connector">  </span>|<span class="connector">  </span> <xsl:text> </xsl:text> </xsl:when> <xsl:otherwise> <span class="connector">    </span> <span class="connector">  </span> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:choose> <xsl:when test="parent::node() and ../child::node()"> <span class="connector">  </span> <xsl:text>|</xsl:text> </xsl:when> <xsl:otherwise> <span class="connector">   </span> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="escape-ws"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, '
')"> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="substring-before($text, '
')"/> </xsl:call-template> <!-- <span class="escape">\n</span> --> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="substring-after($text, '
')"/> </xsl:call-template> </xsl:when> <xsl:when test="contains($text, '	')"> <xsl:value-of select="substring-before($text, '	')"/> <!-- <span class="escape">\t</span> --> <xsl:call-template name="escape-ws"> <xsl:with-param name="text" select="substring-after($text, '	')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> My problem is, that the "|" in the output are present, even if the nodes got no following-nodes. I tried out some logic to avoid this, but I couldn't solve the problem. E.g. I'll get this html-output: |___Tabelle hallo
| |
| |___Tabelle Se
| | |
| | |___Tabelle Serve
| |
| |___Tabelle YoBut I want to get this html-output:
2. Is there a newer version of this great ""Pretty XML Tree Viewer"? Thanks Jonny _________________________________________________________________ E-Mails sind Ihnen nicht schnell genug? http://www.msn.de/messenger MSN Messenger - Kommunikation in Echtzeit
|
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








