我有一个XML文件和一个XSLT样式表文件。
如何在XSLT文件中通过特定的XML字段仅向特定的Excel单元格添加超链接。
我有以下伪代码,但不知道如何在XSLT文件中设置它。
if (xmlAttribute =="Beleg")
{ href = "http://www.xyz.de/beleg.php?beleg=$fieldvalue
}
else if (xmlAttribute == "Lieferant")
{ href = "http://www.xyz.de/lieferant.php?lieferant=$fieldvalue
}
else
{ // no link
}
请问有人可以帮助我吗?
这是我的XML和XSLT:
XML:
<xml>
<s:Schema id="RowsetSchema" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<s:ElementType name="row" content="eltOnly">
<s:AttributeType name="ART">
<s:datatype dt:type="string" dt:maxLength="3" rs:maybenull="false" />
</s:AttributeType>
<s:AttributeType name="BELEG">
<s:datatype dt:type="string" dt:maxLength="63" rs:maybenull="false" />
</s:AttributeType>
<s:AttributeType name="BELEGPOSITION">
<s:datatype dt:type="i2" />
</s:AttributeType>
<s:AttributeType name="BESTELLUNGSDATUM">
<s:datatype dt:type="dateTime" />
</s:AttributeType>
<s:AttributeType name="VERURSACHERARTIKEL">
<s:datatype dt:type="string" dt:maxLength="22" rs:maybenull="false" />
</s:AttributeType>
<s:AttributeType name="WIEDERBESCHAFFUNGSZEIT">
<s:datatype dt:type="i2" />
</s:AttributeType>
<s:AttributeType name="LIEFERANT">
<s:datatype dt:type="string" dt:maxLength="15" />
</s:AttributeType>
<s:AttributeType name="LIEFERANTENNAME">
<s:datatype dt:type="string" dt:maxLength="63" />
</s:AttributeType>
<s:AttributeType name="BEARBEITER">
<s:datatype dt:type="string" dt:maxLength="50" />
</s:AttributeType>
<s:AttributeType name="VERURSACHER">
<s:datatype dt:type="string" dt:maxLength="19" />
</s:AttributeType>
<s:AttributeType name="VERURSACHERPOSITION">
<s:datatype dt:type="string" dt:maxLength="31" />
</s:AttributeType>
<s:AttributeType name="ERSTELLER">
<s:datatype dt:type="string" dt:maxLength="31" />
</s:AttributeType>
<s:AttributeType name="ENDE">
<s:datatype dt:type="dateTime" />
</s:AttributeType>
<s:AttributeType name="BEDARFSTERMIN">
<s:datatype dt:type="dateTime" />
</s:AttributeType>
<s:AttributeType name="LIEFERTERMIN">
<s:datatype dt:type="dateTime" />
</s:AttributeType>
<s:AttributeType name="VERSPAETUNG">
<s:datatype dt:type="int" />
</s:AttributeType>
<s:AttributeType name="UNTERSCHREITUNG">
<s:datatype dt:type="int" />
</s:AttributeType>
<s:extends type="rs:rowbase" />
</s:ElementType>
</s:Schema>
<rs:data xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<z:row ART="ZB" BELEG="982831" BELEGPOSITION="4" BESTELLUNGSDATUM="2012-08-27T00:00:00" VERURSACHERARTIKEL="A16" WIEDERBESCHAFFUNGSZEIT="28" LIEFERANT="123" LIEFERANTENNAME="XXXcOMPANY" BEARBEITER="HarryPotter" VERURSACHER="0.123" VERURSACHERPOSITION="470" ERSTELLER="Max Mustermann" ENDE="2012-12-20T10:10:00" BEDARFSTERMIN="2011-12-19T00:00:00" LIEFERTERMIN="2011-12-31T00:00:00" VERSPAETUNG="-36" UNTERSCHREITUNG="46" />
<z:row ART="ZB" BELEG="982838" BELEGPOSITION="4" BESTELLUNGSDATUM="2012-08-27T00:00:00" VERURSACHERARTIKEL="B16" WIEDERBESCHAFFUNGSZEIT="28" LIEFERANT="134" LIEFERANTENNAME="XXXcOMPANY" BEARBEITER="HarryPotter" VERURSACHER="0.234" VERURSACHERPOSITION="472" ERSTELLER="Max Mustermann" ENDE="2012-12-20T10:10:00" BEDARFSTERMIN="2012-12-19T00:00:00" LIEFERTERMIN="2013-12-31T00:00:00" VERSPAETUNG="-376" UNTERSCHREITUNG="86" />
</rs:data>
</xml>
XSLT 特定部分:
<Row>
<xsl:for-each select="../../s:Schema/s:ElementType/s:AttributeType">
<Cell>
<xsl:variable name="v" select="$x/@*[name()=current()/@name]" />
<xsl:choose>
<xsl:when test="string-length($v)=0">
</xsl:when>
<xsl:when test="s:datatype[@dt:type='dateTime']">
<Data ss:Type="DateTime">
<xsl:value-of select="$v" />
</Data>
</xsl:when>
<xsl:otherwise>
<Data ss:Type="String">
<xsl:value-of select="$v" />
</Data>
</xsl:otherwise>
</xsl:choose>
</Cell>
</xsl:for-each>
</Row>