[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Trouble with value-of


Subject: [xsl] Trouble with value-of
From: "Will Chapman" <xsl_list@xxxxxxxxxxxxxxxx>
Date: Mon, 22 Nov 2004 10:49:34 -0500

Hello Everyone!  I have the following files:

            first.xslt
            ===========================================================
            <?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" version='1.0'>
<xsl:script>
    var currID;
    function getID(node) {
        currID = "ID" + uniqueID(node);
        return currID;
    }
</xsl:script>
 
<xsl:template match="/">
    <xsl:for-each select="/globalmenu/menuitem">
    <div>
        <xsl:attribute
name="onclick">menuClick(<xsl:eval>getID(this)</xsl:eval>, '<xsl:value-of
select="@url"/>');</xsl:attribute>
        <xsl:attribute name="class">mainitemleaf</xsl:attribute>
        <xsl:attribute name="onmouseover">hiliteLeaf(this)</xsl:attribute>
        <xsl:attribute name="onmouseout">normal(this)</xsl:attribute>
        <xsl:value-of select="@label" />
    </div>
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
 

first.xml
===========================================================
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="first.xslt"?> <globalmenu>
    <menuitem label="Home" url="home.html" target="_new" />
    <menuitem label="Products" url="products.html" target="_new">
        <menuitem label="Product 1" url="products_prod1.html" target="_new">
            <menuitem label="Info" url="product1_info.html" target="_new" />
            <menuitem label="Requirements" url="product1_req.html"
target="_new" />
            <menuitem label="Prices" url="product1_prices.html"
target="_new" />
        </menuitem>
        <menuitem label="Product 2" url="products_prod2.html" target="_new">
            <menuitem label="Info" url="product2_info.html" target="_new" />
            <menuitem label="Requirements" url="product2_req.html"
target="_new" />
            <menuitem label="Prices" url="product2_prices.html"
target="_new" />
        </menuitem>
    </menuitem>
    <menuitem label="Services" url="services.html" target="_new">
        <menuitem label="Services 1" url="Services1.html" target="_new" />
        <menuitem label="Services 2" url="Services2.html" target="_new" />
    </menuitem>
    <menuitem label="Contact Us" url="contact.html" target="_new" />
</globalmenu>


Index.html
===========================================================
            <html>
<head>
    <title>Testing</title>
      <link href="global.css" type="text/css" rel="stylesheet" />
    <script src="global.js"></script>
    <script language="javascript" id="clientEventHandlersJS">
<!--
 
 
function insertText(eleID, strText)
{
    document.getElementById(eleID).innerHTML = strText; }
 
function getNodeID() {
            return Math.floor(Math.random() * 18) + 1; }
 
var xmlMenu, xslMenu;
 
function window_onload() {
            try {
                        // create the XML DOM Documents to hold xml content
and XSLT file
                        xmlMenu = new
ActiveXObject("MSXML2.DOMDocument.3.0");
                        xslMenu = new
ActiveXObject("MSXML2.DOMDocument.3.0");
                        // make sure they load asynchronously
                        xmlMenu.async = false;
                        xslMenu.async = false;
                        xmlMenu.load("first.xml");
                        xslMenu.load("first.xslt");
                        divMain.innerHTML = transformContent(xmlMenu,
xslMenu);
            }
            catch(e) {
                        divMain.innerHTML = e.description;
            }
}
//-->
</script>
</head>
<body style="FONT-SIZE: 12pt; COLOR: white" bgcolor="black" leftmargin="5"
topmargin="5" onload="return window_onload()">

    <div id="divMain">loading...</div>

 

    <div id="debugDump" style="background-color: #ffffff; color: #0000ff;
width: 100%; height: 100%; top: 150px; left: 0px; position: absolute;">
        Dumping...
    </div>
</body>
</html>
 
 
Then there is a javascript file which I will not bother posting.  Its not
important as of right now.
 
Here is my question.  I am trying to get just the first level of the
<menuitem> to display inside of a <DIV> tag correctly.  The problem is that
when I put it as you see it now, I get just the text, like 'Home",
"Products", "services' etc.  However, I can take the <xsl:value-of./> part
out and it will generate the <DIV> tag, but it will output the label first,
then the div tag.. so its nested incorrectly.  Can anyone point me in the
right direction as to why this would happen or perhaps a more detailed
article that I can read about this.  I admit, this is not 100% my code.  I
downloaded it from the internet and am hacking it up to learn XSL in more
detail.

 Thanks for any input!

Will


Current Thread
Keywords