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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml and xsl and javascript. problem!

Status
Not open for further replies.

birney29

Programmer
Oct 11, 2001
140
GB
here's the problem im having:

im trying to use and xsl document to transform data in an XML document into HTML. Simple enough. However, im also using the XSL document (with Javascript) to format the HTMl page i.e. Text size, color ect, by taking values from another XMl document. a sort of xml coniguration file. however, the html document just comes up as black with no text, why? The code for the three files is below:

<?xml version=&quot;1.0&quot; ?>
<UICONFIG>
<config>
<backcolor>#000000</backcolor>
<fontcolor>#ff0000</fontcolor>
<fontsize>Large</fontsize>
</config>

</UICONFIG>

<?xml version=&quot;1.0&quot;?>
<xsl:Stylesheet version = &quot;1.0&quot; xmlns:xsl=&quot;<xsl:eek:utput method=&quot;html&quot;/>

<xsl:template mach=&quot;/&quot;>
<html>
<head>
<title> Fromatted data through xsl, 2 xml documents and Javascript </title>
</head>
<body onload = &quot;init()&quot; id=&quot;body&quot;>

<SCRIPT LANGUAGE=&quot;javascript&quot;>
function init()
{
testXML.async = false;
testXML.load(&quot;./ui.xml&quot;);

formatUI(testXML);
}

function formatUI(testXML)
{
i = 0;
itemElement = testXML.documentElement.childNodes.item(i);
document.bgColor = itemElement.childNodes.item(0).childNodes.item(0).nodeValue;
document.fgColor = itemElement.childNodes.item(1).childNodes.item(0).nodeValue;
document.all.body.style.fontSize= itemElement.childNodes.item(2).childNodes.item(0).nodeValue;
}

</SCRIPT>

<xsl:apply-templates select=&quot;//Person&quot;/>

</body>

<XML ID=&quot;testXML&quot;>
</XML>

</html>
</xsl:template>

<xsl:template match =&quot;Person&quot;>
<H1> <xsl:value-of select = &quot;Name&quot;/> </H1>
<b> <xsl:value-of select = &quot;Job&quot; /> </b>
<p> <xsl:value-of select = &quot;Details&quot;/> </p>
</xsl:template>

</xsl:Stylesheet>

<?xml version=&quot;1.0&quot; standalone = &quot;yes&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;UIConfigStyle.xsl&quot; ?>
<data>
<Person>
<Name> Kenny Birney </Name>
<Job> Programmer </Job>
<Details> This data has been transformed into HTML through xsl and formatted through JavaScript and xml </Details>
</Person>
</data>

Thanks for your help

Kenny Birney.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top