Click to See Complete Forum and Search --> : adding navigation buttons to xml


code1red
11-28-2008, 11:14 AM
Is it possible to add flash navigation buttons to xml? Im not sure what to do, the buttons are on the index.htm attachment and I am also including the xml and xsl pages in the zip file.

I need to have consistent navigation, So I want to use those buttons on the index and put them in the same position on the data.xml page.

rpgfan3233
11-28-2008, 10:10 PM
Of course! Any element can work for this. Just make sure that the XSLT transforms the XML elements to the actual elements for the Flash buttons. For example, supposing you had a <flash-navbutton/> tag in your XML, you could use <xsl:apply-templates/> at whatever point you wanted in your XSLT document, and the following template should work for you (if your HTML code is right, I just copied, pasted and re-indented):
<xsl:template match="flash-navbutton">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="105" height="21">
<param name="movie" value="button1.swf" />
<param name="quality" value="high" /><param name="BGCOLOR" value="#00CCFF" />
<embed src="button1.swf" width="105" height="21" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#00CCFF" ></embed>
</object>
</xsl:template>

As XML has no real functionality in terms of interactivity, the JavaScript code that is currently in index.html would be unusable. I see that you have a noscript element containing what appears to be the exact same stuff as the JavaScript, so why are you using JavaScript in the first place? :p

code1red
11-29-2008, 12:26 AM
I dont know what you mean about the javascript, I just used dreamweavers feature where you insert flash buttons and dreamweaver inserts all the necessary code.

your code didnt work for me, not sure if I did it right. on the xml page I have this

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="data.xsl"?>

<!DOCTYPE data
[
<!ELEMENT data (about*)>
<!ELEMENT about (title, sub, flash-navbutton, name, bday, born, gender)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT sub (#PCDATA)>
<!ELEMENT flash-navbutton (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT bday (#PCDATA)>
<!ELEMENT born (#PCDATA)>
<!ELEMENT gender (#PCDATA)>
]
>
<data>

<about>
<title>Assignment 10</title>
<sub>Data</sub>
<flash-navbutton> </flash-navbutton>
<name>Joel Pifer</name>
<bday>May 17, 1990</bday>
<born>PA</born>
<gender>Male</gender>

</about>

</data>

and for the part of the XSLT that included anything with the navigation I have this

<!-- NAVIGATION BEGIN -->
<xsl:apply-templates>

<xsl:template match="flash-navbutton">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="105" height="21">
<param name="movie" value="button1.swf" />
<param name="quality" value="high" /><param name="BGCOLOR" value="#00CCFF" />
<embed src="button1.swf" width="105" height="21" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#00CCFF" ></embed>
</object>
</xsl:template>
</xsl:apply-templates>

<!-- NAVIGATION END -->

that didnt add the navigation. it took everything inside the element tags on my xml page and repeated it, but it wasnt styled like the rest.

rpgfan3233
11-29-2008, 01:15 PM
It would be more like the following example:
<xsl:template match="flash-navbutton">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
width="105" height="21">
<param name="movie" value="button1.swf" />
<param name="quality" value="high" />
<param name="BGCOLOR" value="#00CCFF" />
<embed src="button1.swf" width="105" height="21" quality="high"
pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash"
bgcolor="#00CCFF"></embed>
</object>
</xsl:template>

<xsl:template match="/">
<span style="text-align:center; background-color:#00CCFF">
<xsl:for-each select="data/about">
<p>
<h2><xsl:value-of select="title" /></h2>
<h3><xsl:value-of select="sub" /></h3> <br />

<xsl:apply-templates select="flash-navbutton" />

<span style="font-style:italic; font-size:20px;
font-weight: bolder; color: #00CC00">
<xsl:value-of select="name" />
</span><br />

Notice the use of xsl:apply-templates. Any time you want to use that Flash navbutton, you would just use that line. It should work then (maybe not in Dreamweaver).

code1red
11-29-2008, 05:06 PM
ok awesome. that works for me. thank you.