[no subject]
Hi,
I just begin in XSL-server side and I want to search in particular xml
element in a xml file and I know that I have more than one element that
correspond to ... I do tests with the selectSingleNode and I have good
result except that I only have the first element of the matching pattern
... In fact, I do other tests with the selectNodes method (...method who
return all the element ...) but with no success ...
Can somebody help me,
That will be nice...
Eric
Here is the asp file:
<%@ LANGUAGE = JScript %>
<%
// Error formatting function:
function reportError(where, error)
{
Response.Write("<font
face=Arial><B>Error loading '" + where +
"'</B></font> <BLOCKQUOTE><XMP>" +
error.reason + "</XMP></BLOCKQUOTE>");
}
// Load the XML
var xmlDoc =
Server.CreateObject("Microsoft.XMLDOM");
xmlDoc.async = false;
var weed = Request.QueryString("weed");
var fileName = "Xml/PlantTypes.xml";
xmlDoc.load(Server.MapPath(fileName));
if (xmlDoc.parseError.errorCode != 0)
{
reportError(fileName, xmlDoc.parseError);
}
else
{
// Load the stylesheet
var style =
Server.CreateObject("Microsoft.XMLDOM");
style.async = false;
var fileName = "Xsl/weed.xsl";
style.load(Server.MapPath(fileName));
if (style.parseError.errorCode != 0)
{
reportError(fileName,
xmlDoc.parseError);
}
// Process it
var pattern =
"/SgPlantTypes/SgPlantType[@ID='" + weed + "']";
var node =
xmlDoc.documentElement.selectNodes(pattern);
var result = node.transformNode(style);
Response.Write(result);
}
%>
and here is the xsl file:
<?xml version="1.0"?>
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<HEAD>
</HEAD>
<BODY STYLE="font-family:Arial, helvetica, sans-serif;
font-size:12pt;
background-color:#FDF5B5">
<TABLE
BORDER="0">
<tr>
<td><SPAN
STYLE="margin-left:8pt; font-size:11pt; font-weight:bold;
padding-top:3pt;
padding-bottom:3pt;">MAUVAISE HERBE:</SPAN>
</td>
</tr>
<TR>
<TD>
<xsl:for-each select="node()">
<DIV STYLE="margin-left:26pt; margin-right:1pt; font-size:10pt;
font-weight:bold; padding-top:0pt;">
<xsl:value-of select="@NAME"/>
</DIV>
</xsl:for-each>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Current Thread |
- [no subject]
- Éric Riblair - Wed, 23 Dec 1998 15:30:34 -0500 <=
|