Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transform xml to xhtml

Status
Not open for further replies.

henryhandle

Programmer
Feb 19, 2005
56
DE
hello,
I 'm trying to transform
XML to XHTML in Browser
and i use this Javascript to make a Sever side transform:


<html><head><title>SML</title>

<script language="JavaScript">
function transformXXX(){
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("myxml.xml")
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("myxsl.xsl")
document.write(xml.transformNode(xsl))
}
</script>
</head>
<body>
<p>Transform </p>
<form name="xmlsxl">
<p><input type="button" value="XMLTransformXSL" onClick="transformXXX()"> </p>
</form>
</body>
</html>

when i save this file and put my xml and xsl files in
the same directory it happend nothing!

my qestion is how i get xhtm from xsl and xml file?
what do i make wrong?

i ' m appreciated for your help
 
I tried your code and it works fine. Presuming you have javascript enabled in your browser, the problem must be your XSL or XML file. Post them.

This is not a server side transformation, its client-side. To transform server side, you'll need to use some sort of technology such as ASP, PHP or Java.

You can simply reference a stylesheet at the top of an XML file to perform the transform, by using:

<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>

See:

 
thanks,

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>
<Job>
<JOBID>14586</JOBID>

</Job>
########
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="html"/>
<xsl:template match="/Job">
<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

</head><body>

<table><tr><td><b>Order:</b></td><td>
<xsl:value-of select="JOBID"/></td></tr></table>
</body></html></xsl:template></xsl:stylesheet>
 
hello, it still dont work :(
in browser is javascript enabled too!
please have a look in my xsl and xml files.
maybe you see what is wrong!
thanks!
here are both files:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>
<Job>
<JOBID>14586</JOBID>

</Job>
########
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="html"/>
<xsl:template match="/Job">
<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

</head><body>

<table><tr><td><b>Order:</b></td><td>
<xsl:value-of select="JOBID"/></td></tr></table>
</body></html></xsl:template></xsl:stylesheet>
 
Works fine for me. You have all the files in the same directory and they are called myxsl.xsl and myxml.xml?
 
maybe i did'nt understand something important,
what is the goal of this javascript to make an output
file or only to let browser to show the result of
xml and xsl files (without generate of file)?
that is what i understand, when i use this Javascript:
get in Javascript two parameter: myxsl.xsl and myxml.xml and
the result is a out.html
?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top