我对这个 xslt 很陌生,或者我很笨。请帮忙。我有一个输入类型选择(下拉),下面给出了三个选项 - .Xml 和 xslt。我只得到空白下拉列表。如何设置选定的值进入下拉????。在我的情况下,一个下拉必须选择“仅查看”和另一个“完全访问”。:(
XML
<PagedResult xmlns="xxxxx/Object" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<RowCount>1</RowCount>
<PageCount>1</PageCount>
<Errors />
<ResultsPerPage>1</ResultsPerPage>
<CurrentPage>1</CurrentPage>
<Rows>
<SearchResultShare>
<ShareUserPrivilege>View Only</ShareUserPrivilege>
</SearchResultShare>
<SearchResultShare>
<ShareUserPrivilege>Full Access</ShareUserPrivilege>
</SearchResultShare>
</Rows>
</PagedResult>
XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pg="xxxxx/Object">
<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" indent="no"/>
<xsl:decimal-format name="us" NaN="n/a"/>
<pg:options>
<option>Select</option>
<option>Full Access</option>
<option>View Only</option>
</pg:options>
<xsl:variable name="options" select="document('')//pg:options/*"/>
<xsl:template match="/pg:PagedResult">
<xsl:choose>
<xsl:when test="pg:Errors/node()">
<ul>
<xsl:apply-templates select="pg:Errors"/>
</ul>
</xsl:when>
<xsl:when test="pg:RowCount = 0">
<div class="tableBorderColorBGrnd tableBorderColor tableHeader">
<table class="primaGridViewSmall" cellspacing="0" cellpadding="1" border="0" width="100%">
<tr valign="bottom">
<th style="width: 3%;text-align: left;"></th>
</tr>
</table>
</div>
<table class="primaGridViewSmall" cellspacing="0" cellpadding="1" border="0" width="100%">
<tr>
<td style="padding: 3px;">Your search did not return any share users.</td>
</tr>
</table>
</xsl:when>
<xsl:otherwise>
<div class="tableBorderColorBGrnd tableBorderColor tableHeader">
<table id="tblSearchResultsHeader" class="primaGridViewSmall" cellspacing="0" cellpadding="1" border="0" width="100%">
<tr valign="bottom">
<th style="width: 3%;text-align: left;"></th>
</tr>
</table>
</div>
<div id="searchResultsTable" class="resultsContainer1">
<table id="tblSearchResults" class="primaGridViewSmall" cellspacing="0" cellpadding="1" border="0" width="100%">
<xsl:apply-templates select="pg:Rows"/>
</table>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="pg:SearchResultShare">
<tr>
<td style="width: 10%;text-align: left;">
<xsl:variable name="ShareUserPrivilege" select="pg:ShareUserPrivilege"/>
<select id="ShareUserPrivilege">
<xsl:for-each select="$options">
<option value="{.}">
<xsl:if test=". = $ShareUserPrivilege">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>
<xsl:value-of select="."/>
</option>
</xsl:for-each>
</select>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
输出
<div xmlns:pg="xxxxx/Object" class="tableBorderColorBGrnd tableBorderColor tableHeader"><table id="tblSearchResultsHeader" class="primaGridViewSmall" cellspacing="0" cellpadding="1" border="0" width="100%">
<tr valign="bottom"><th style="width: 3%;text-align: left;"></th></tr>
</table>
</div><div xmlns:pg="xxxxx/Object" id="searchResultsTable" class="resultsContainer1">
<table id="tblSearchResults" class="primaGridViewSmall" cellspacing="0" cellpadding="1" border="0" width="100%">
<tr><td style="width: 10%;text-align: left;"><select id="ShareUserPrivilege">
</select></td>
</tr>
<tr><td style="width: 10%;text-align: left;"><select id="ShareUserPrivilege">
</select></td>
</tr>
</table></div>
我想要的是
在页面加载时,“ShareUserPrivilege”例如:仅查看,从数据库中选择值用户。所以在页面加载时,我需要将下拉选择的索引设置为该值,即“完全访问”插入“选择” . 目前它没有设置选定的值总是以“<--Select-->”的形式出现。
Eg:
<--Select--> selected index -1
View Only selected index 0
Full Access selected index 1
在编辑页面中,用户已经选择说“完全访问”选择的索引是 1,我已经将选择的索引值 1 存储到数据库中。所以现在在列表页面(或查看页面)中,我需要列出这些结果。有下降down 必须设置为“完全访问”。如何?
output needed
Full Access selected index 1
<--Select-> selected index -1
View Only selected index 0