I am working on creating an html report from two xml sources. The
first source is the xml that needs to be displayed in the report. The
second source is used to populate a select box. The problem i'm having
is with the multiple for-each's necessary to do this. In the
for-each's I need to generate unique id's, name's and for's in a way
that they can be processed server side later.
Here is what I currently have:
----test.xsl----
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" encoding="utf-8"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
<xsl:variable name="priorities"
select="document('priorities.xml')" />
<xsl:template match="/">
<html>
<head>
<title>Test</title>
</head>
<body>
<form action="transform.aspx" method="post">
<table border="1" cellpadding="4">
<tr>
<td><strong>Request Date</strong></td>
<td><strong>Change Title</strong></td>
<td><strong>Status</strong></td>
<td><strong>Action</strong></td>
</tr>
<xsl:for-each select="/AC_Requests/AC_Request">
<tr>
<td><xsl:value-of select="@RequestDate"
/></td>
<td><xsl:value-of select="@ChangeTitle"
/></td>
<td><xsl:value-of select="@StatusID"
/></td>
<td>
<label for="action">Priority:
</label>
<select id="action"
name="action">
<option
value="0">Select an action</option>
<xsl:for-each
select="$priorities/priorities/priority">
<option
value="{(_at_)priority_id}"><xsl:value-of
select="@priority" /></option>
</xsl:for-each>
</select>
<input type="submit"
name="submit" value="Go" />
</td>
</tr>
</xsl:for-each>
</table>
</form>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
---- test.xml ----
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<AC_Requests>
<AC_Request RequestDate="2005-03-09 9:11:56" ChangeTitle="test"
StatusID="3"/>
<AC_Request RequestDate="2005-03-09 9:12:44" ChangeTitle="test"
StatusID="3"/>
<AC_Request RequestDate="2005-03-09 9:14:15" ChangeTitle="test"
StatusID="2"/>
</AC_Requests>
---- priorities.xml ----
<?xml version="1.0"?>
<priorities>
<priority priority_id="1" priority="Hold"/>
<priority priority_id="2" priority="High"/>
<priority priority_id="3" priority="Med"/>
<priority priority_id="4" priority="Low"/>
</priorities>
---- OUTPUT ----
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test</title>
</head>
<body>
<form action="transform.aspx" method="post">
<table border="1" cellpadding="4">
<tr>
<td>
<strong>Request Date</strong>
</td>
<td>
<strong>Change Title</strong>
</td>
<td>
<strong>Status</strong>
</td>
<td>
<strong>Priority</strong>
</td>
<td>
<strong>Action</strong>
</td>
</tr>
<tr>
<td>2005-03-09 9:11:56</td>
<td>test</td>
<td>3</td>
<td>
<select id="action" name="action">
<option value="0">Select an action</option>
<option value="1">Hold</option>
<option value="2">High</option>
<option value="3">Med</option>
<option value="4">Low</option>
</select>
</td>
<td>
<input type="submit" name="submit" value="Go">
</td>
</tr>
<tr>
<td>2005-03-09 9:12:44</td>
<td>test</td>
<td>3</td>
<td>
<select id="action" name="action">
<option value="0">Select an action</option>
<option value="1">Hold</option>
<option value="2">High</option>
<option value="3">Med</option>
<option value="4">Low</option>
</select>
</td>
<td>
<input type="submit" name="submit" value="Go">
</td>
</tr>
<tr>
<td>2005-03-09 9:14:15</td>
<td>test</td>
<td>2</td>
<td>
<select id="action" name="action">
<option value="0">Select an action</option>
<option value="1">Hold</option>
<option value="2">High</option>
<option value="3">Med</option>
<option value="4">Low</option>
</select>
</td>
<td>
<input type="submit" name="submit" value="Go">
</td>
</tr>
</table>
</form>
</body>
</html>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--