【发布时间】:2017-03-27 11:01:51
【问题描述】:
我有 2 个单选按钮,名称为 cube 1 和 cube 2。在这个单选按钮下方,我在我列出的特定列中获取记录。
我的 XML 文件是 data.xml 和 data1.XML,它们都是相同的,但是在检查不同的单选按钮时会被调用
如果选择了多维数据集 1 单选按钮,它将从 data.XML 文件中选择数据,当我单击多维数据集 2 单选按钮时,它将从 Data1.xml 文件中选择数据。
现在我需要将它们结合起来..
Xslt 文件如下:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body style="font-family:Helvetica Neue">
<Div id="ListingScreen">
<table border="1" width="1024px" >
<tr bgcolor="blue">
</FONT>
</tr>
<tr>
<td align="right" colspan="10">
</td>
</tr>
<tr>
<td colspan="10">
<input id="cube1" type="radio" name="Cube" value="1" checked="true"> Cube1</input>
<input id="cube2" type="radio" name="Cube" value="2">Cube2</input>
</td>
</tr>
<tr>
</tr>
<tr>
<th>ID</th>
<th id="location">Location ID</th>
<th>Data Entry</th>
<th>Export</th>
<th>Local View</th>
<th>Banner</th>
<th>Server</th>
<th>View</th>
<th>Locl</th>
</tr>
<xsl:choose>
<xsl:when test="CATALOG/orderByTitle">
<xsl:apply-templates select="CATALOG/CD">
<xsl:sort select="TITLE" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="CATALOG/orderByTitleDesc">
<xsl:apply-templates select="CATALOG/CD">
<xsl:sort select="TITLE" order="ascending" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="CATALOG/orderByArtist">
<xsl:apply-templates select="CATALOG/CD">
<xsl:sort select="ARTIST" />
</xsl:apply-templates>
</xsl:when>
</xsl:choose>
</table>
</Div>
</body>
</html>
</xsl:template>
<xsl:template match="CD" >
<tr>
<td>
<xsl:value-of select="ID" />
</td>
<p style="display:none;">
<xsl:value-of select="ID"/>
</p>
<xsl:value-of select="LocationID"/>
</a>
</td>
<td>
<input type="checkbox" name="DataEntry" value="dataentry">
<xsl:if test="DataEntry='Yes'">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</td>
<td>
<input type="checkbox" name="Export" value="export">
<xsl:if test="Export='Yes'">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</td>
<td>
<input type="checkbox" name="LocalView" value="localview">
<xsl:if test="LocalView='Yes'">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</td>
<td>
<xsl:value-of select="Banner"/>
</td>
<td>
<xsl:value-of select="Server"/>
</td>
<td>
<xsl:value-of select="View"/>
</td>
<td>
<xsl:value-of select="Location01"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
我的xml文件如下:格式相同 1)Data.xml 2)Data1.xml
<?xml version="1.0" standalone="yes"?>
<CATALOG>
<orderByTitleDesc />
<orderByTitleDesc />
<orderByTitleDesc />
<orderByTitleDesc />
<orderByTitleDesc />
<orderByTitleDesc />
<orderByTitleDesc />
<orderByTitleDesc />
<CD>
<ID>1</ID>
<LocationID>Location</LocationID>
<ChangeValueFor>Data per Subclass</ChangeValueFor>
<Banner>Forecast is open</Banner>
<DataEntry>Yes</DataEntry>
<LocalView>Yes</LocalView>
<Export>Yes</Export>
<View>1</View>
<ActiveView>Data</ActiveView>
<HelpFile>Testfile</HelpFile>
<Location01>1</Location01>
<Location02>2</Location02>
<Location03>3</Location03>
<Location04>4</Location04>
<Location05>5</Location05>
<Location06>6</Location06>
<Location07>7</Location07>
<Location08>8</Location08>
<Location09>9</Location09>
<Location10>10</Location10>
<Location11>11</Location11>
<Location12>12</Location12>
<Server>KLJJLK</Server>
<Server2>Select</Server2>
<Server3>Select</Server3>
<CodeBase>HKJHJKK</CodeBase>
<CodeBase2>NA</CodeBase2>
<CodeBase3>NA</CodeBase3>
<ClassiscID>KLJLKJLJ</ClassiscID>
<ClassiscID2>NA</ClassiscID2>
<ClassiscID3>NA</ClassiscID3>
<Theme>Cubus</Theme>
<Theme2>NA</Theme2>
<Theme3>NA</Theme3>
<Theme4>NA</Theme4>
<Theme5>NA</Theme5>
<Theme6>NA</Theme6>
</CD>
</CATALOG>
第二个文件 Data1.xml 看起来与相同的标签相同,只是更改了值。现在我如何在检查单选按钮时调用不同的 data.xml 或 data1.xml。
【问题讨论】:
标签: xml xslt xslt-1.0 datasource xslt-2.0