INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

XSL/XML - Data-binding controls on displayed page

XSL/XML - Data-binding controls on displayed page

XSL/XML - Data-binding controls on displayed page

(OP)
Hello - I am very new to XML/XSL so I don't know if what I am trying to do is possible (or recommended).

I have an XML file (generated via an Excel macro) that contains drawing information.

XML File:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Drawings.xsl"?>
<Drawings>
<Drawing>
<District><![CDATA[myCity]]></District>
<PartName><![CDATA[Valve1]]></PartName>
<PartNumber><![CDATA[09T-202]]></PartNumber>
<Section><![CDATA[9]]></Section>
<PartCode><![CDATA[D]]></PartCode>
<URL><![CDATA[https:www.myserver/drawings/09T-202.pdf]]></URL>
</Drawing>
<Drawing>
<District><![CDATA[myCity]]></District>
<PartName><![CDATA[Valve2]]></PartName>
<PartNumber><![CDATA[09T-301]]></PartNumber>
<Section><![CDATA[9]]></Section>
<PartCode><![CDATA[P]]></PartCode>
<URL><![CDATA[https:www.myserver/drawings/09T-301.pdf]]></URL>
</Drawing>
<Drawing>
<District><![CDATA[myCity]]></District>
<PartName><![CDATA[Valve3]]></PartName>
<PartNumber><![CDATA[09T-303R]]></PartNumber>
<Section><![CDATA[9]]></Section>
<PartCode><![CDATA[C]]></PartCode>
<URL><![CDATA[https:www.myserver/drawings/09T-303R.pdf]]></URL>
</Drawing>

I have an XSL file that puts the drawing names in an HTML "Select" drop-down list.
In the XSL file, I also have javascript code that displays the <URL> node PDF file link in a frame on the page based on the selection.
This is all working great.

XSL file:
<?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>
<script language="javascript" DEFER="true">
<xsl:comment>
<![CDATA[

function LoadPDFtoIFRAME(url)
{
var PDFcontrol1 = document.getElementById("PDFiframe");
PDFcontrol1.src=url + "#&toolbar=0&navpanes=0";
}
]]>
</xsl:comment>
</script>
</head>

<body>
<table>
<tr>
<td>
<h2>Drawings</h2>

<select name="PDFSelect" id="PDFSelect" onchange="javascript:LoadPDFtoIFRAME(PDFSelect.options[PDFSelect.selectedIndex].value)">
<option selected="true">Select a drawing</option>
<xsl:for-each select="Drawings/Drawing">
<xsl:sort select="PartName"/>
<option>
<xsl:attribute name="value"><xsl:value-of select="URL"/></xsl:attribute>
<xsl:value-of select="PartName" />
</option>
</xsl:for-each>
</select>
</td>
<td>
<iframe id="PDFiframe" src="" height="800" width="600"></iframe>
</td>

</tr>
</table>
</body>
</html>

</xsl:template>
</xsl:stylesheet>


My Problem:
I want to add HTML "<div>"s or read-only "Text" boxes that will display related info from the XML file based on the selection in the list (for example "PartNumber" and "PartCode"). I have done something simliar before by parsing XML files using javascript arrays .

When this page is displayed in the browser however, it is ".xml", and therefore I cannot call itself from a javascript XML parser function within the XSL file.

Is there another method using XSL (or should I scrap XSL and just do it the "old" way)?

Very greatful for any suggestions!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close