Link to home
Start Free TrialLog in
Avatar of racing_chicken
racing_chicken

asked on

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));
%>
Avatar of racing_chicken
racing_chicken

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial