• 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"?>
<XMLDOC>
    <BORDERS>
        <BORDER id="top">
            <table border="0" width="812">
                <tr>
                    <td width="180">
                      <a href="test2.htm">
                        <img src="images/apahome.gif"></img>
                      </a>
                    </td>
                    <td valign= "center" align="center" width="618">
                      <img src= "images/apa_logo_sm.jpg" width="50" height="35"></img>
                      <b>
                        <font size="7"> San Gabriel Valley APA </font>
                      </b>
                      <img src= "images/apa_logo_sm.jpg" width="50" height="35"></img>
                   </td>
                </tr>
            </table>
        </BORDER>
        <BORDER id="left">
        </BORDER>
        <BORDER id="bottom">
        </BORDER>
    </BORDERS>
    <DIVISIONS>
    ...
    ...
    </DIVISIONS>
</XMLDOC>         

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="" />
  <title></title>
  </head>
- <body link="#0000FF" vlink="#0000FF" alink="#FF0000">
- <!--   table 1  -->


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


- <!--  table 2  -->
  <table border="0" width="800">
...
...
</table>
  </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>


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
  source.load(sourceFile);

  // Load the XSLT
  var style = Server.CreateObject("Msxml2.DOMDocument");
  style.async = false;
  style.resolveExternals = false
  style.load(styleFile);
  Response.Write(source.transformNode(style));
%>
0
racing_chicken
Asked:
racing_chicken
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.
0
 
COBOLdinosaurCommented:
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.

Cd&
0

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