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="
<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!
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="
<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!