• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

How to Use XSL to publish entire XML node, including tags, to HTML?

I want to publish everything in the <border ID="top"> node of the XML Document below to html using the xsl sytlesheet below, including the tags. As it is now, I have three borders hard coded into the xsl document, and I'm going to have at least 10 different xsl files, so it's much easier to edit the XML than cut and paste ad infinitum.  What is the easiest and/or best way to use the xsl to do this?

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl"?>
        <BORDER id="top">
            <table border="0" width="812">
                    <td width="180">
                      <a href="test2.htm">
                        <img src="images/apahome.gif"></img>
                    <td valign= "center" align="center" width="618">
                      <img src= "images/apa_logo_sm.jpg" width="50" height="35"></img>
                        <font size="7"> San Gabriel Valley APA </font>
                      <img src= "images/apa_logo_sm.jpg" width="50" height="35"></img>
        <BORDER id="left">
        <BORDER id="bottom">

XSL stylesheet
<?xml version="1.0" encoding="iso-8859-1" ?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:template match="/">
- <html>
- <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
  <meta name="copyright" content="" />
  <meta name="author" content="" />
- <body link="#0000FF" vlink="#0000FF" alink="#FF0000">
- <!--   table 1  -->

- <!--  WHAT GOES HERE?   -->

- <!--  table 2  -->
  <table border="0" width="800">

ASP File
<%@ LANGUAGE = JavaScript %>
  sXSL = "test.xsl"
  // Set the source and style sheet locations here
  var sourceFile = Server.MapPath("apa.xml");
  var styleFile = Server.MapPath(sXSL);

  // Load the XML
  var source = Server.CreateObject("Msxml2.DOMDocument");
  source.async = false;
  source.resolveExternals = false

  // Load the XSLT
  var style = Server.CreateObject("Msxml2.DOMDocument");
  style.async = false;
  style.resolveExternals = false
1 Solution
racing_chickenAuthor Commented:
Is this question too wierd, too stupid or is no one listening?

I realize there are other ways to do this by making the XML Doc a little more normal, but the XML is well-formed and if it could be done, it would be a tremendous timesaver. I doubt I could write a DTD or schema for it, though.
Well it is possible that no one understands what it is you are trying to do; or the experts looking at the authorig topic are not XML experts; or they are trying to figure out the connection between the xsl and the client side scripting being generated by the server side script.

My xml skills re pretty limited but if what you ae trying to do is preserve the formatting of the block could you not just put it in a CDATA section?

I think you might be wise to post a pointer to this thread in the XML topic to get experts that may be better equipt to address your problem.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now