Retrieving attributes

admin

Administrator
Staff member
Hi all,

I am relatively new to XML, but I think I'm making good progress. However I'm a little stuck on the following problem.

I have an XML file which is...

<?xml version="1.0" encoding="utf-8"?>
<DistributionLists>
<List2 DLN="Distributors" DLID="2">
<member>
<ID>12345</ID>
<N>ESL</N>
<L>2</L>
</member>
</List2>
<List1 DLN="My Downline" DLID="1">
<member>
<ID>12345</ID>
<N>ESL</N>
<L>2</L>
</member>
</List1>
<List8 DLN="test" DLID="8">
<member>
<ID>11404</ID>
<N>RHT</N>
<L>7</L>
</member>
<member>
<ID>9333</ID>
<N>TC</N>
<L>7</L>
</member>
</List8>
</DistributionLists>


What I'm trying to achieve in part of my XSL file is to retrieve each and every attribute of "DLN" and place this into a drop-down box, with the value being the attribute of "DLID"

At the moment, I have...
(note, this is only a small snippet of the file)


<xsl:template match="DistributionLists">
<xsl:param name='sort' select="'N'" />
<xsl:variable name="maxRecord" select="count(*[local-name()=$distList]/*)" />
<HTML>
<BODY>
<TABLE id="tblResults" cellSpacing="0" cellPadding="5" width="100%" align="center" border="0">
<script language="JScript">
for (i=1; i<Math.ceil(<xsl:value-of select="$maxRecord" />/<xsl:value-of select="$pageSize" />)+1; i++)
{
var newElem=document.createElement("OPTION");
newElem.text = i;
newElem.value = i;
Form1.ddlPageNumber.add(newElem);
}
</script>
<xsl:for-each select="*">
<script language="JScript">
var newElem=document.createElement("OPTION");
newElem.text = <xsl:value-of select="@DLN" />
newElem.value = i;
Form1.ddlDistributionList.add(newElem);
</script>
</xsl:for-each>


The last part is where I'm trying to retrieve the attribute DLN. The drop-down list IS being created x-number of entries in the XML file, so the selection is working, but I was under the impression that to select an attribute, I use the @ sign.

I've even tried changing the line to read...
newElem.text = <xsl:value-of select="/member/@DLN" />
But this again doesn't work.

The final thing I did was to have...

newElem.text = <xsl:attribute select="{@DLN}" />

But then I get a QWord error when the attribute content is in two parts!

Any ideas to achieve what I want...?

Many thanks,
 
Back
Top