Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 10th, 2004, 06:22 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML to XML

Hi,

I have one XML file like below. I put only one node for Document below. I want to use XSL to display the XML as it is. Means I want to display the XML as HTML such that on the browser it looks like XML.

<?xml version="1.0"?>
<Documents>
 <Count> 20 </Count>
 <Document>
   <DocNo> 123 </DocNo>
   <DocType> Application </DocType>
  </Document>
 </Document>
</Documents>


Output HTML should show the data similar to that of XML as shown above. Is there any generic XSL to get that result.


 
Old March 10th, 2004, 08:34 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

First attempt:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html><head><title>Raw Data</title></head></html>
    <body>
      <textarea rows="40" cols="60">
        <xsl:apply-templates/>
      </textarea>
    </body>
  </xsl:template>
  <xsl:template match="node()|@*">

    <xsl:copy>

      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
The document you gave as an example is not xml as you have one extra [code]</document>[code] tag.

--

Joe
 
Old March 12th, 2004, 05:50 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,

Thanks for your reply. Is there any other way to get the output without <textarea> html element. I want to display it on html page.

If I remove the <textarea> it's displaying the simple text.

Thanks in advance,
Satya

 
Old March 12th, 2004, 06:58 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

This might work but then you lose the identation.
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html><head><title>Raw Data</title></head></html>
    <body>
      <xmp>
        <xsl:apply-templates/>
      </xmp>
    </body>
  </xsl:template>
  <xsl:template match="node()|@*">

    <xsl:copy>

      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
What's wrong with the one IE normally uses? It's at URL res://msxml3.dll/defaultss.xsl or for a more modern one in XSLT http://www.biglist.com/lists/xsl-lis.../msg00769.html. You'll need to remove a stray semi-colon on line 12. For an examination of this problem further try

http://groups.google.com/groups?hl=e...3DN%26tab%3Dwg

--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2005 XML: FOR XML PATH -> cdata? stoves SQL Server 2005 1 July 8th, 2008 02:40 AM
Creating XML doc ; writing string(xml format) into KamalRaturi XML 5 May 28th, 2008 05:51 AM
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
xml invalid top level from ASP write XML(solution) g000we XML 0 August 9th, 2006 03:56 AM
DTS Package, XML task. Read XML file and store it Victoria SQL Server DTS 0 July 24th, 2006 02:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.