2013-03-28 184 views
0

我正在使用以下xml並希望使用xslt在HTML中顯示。如何在xsl中創建超鏈接

<resultDetailsData> 
    <itemProperties> 
     <ID>0</ID> 
     <type>RESULTSTATUS</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="status">NOSTATUS</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>1</ID> 
     <type>LEVEL</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>2</ID> 
     <type>RESULTTYPE</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="resultType">SCREENIMAGE</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>3</ID> 
     <label>Description</label> 
     <type>TEXT</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">SC</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>4</ID> 
     <type>LINK</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2013-03-25 111117-840.jpg</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>5</ID> 
     <type>SCREENSHOT</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2013-03-25 111117-840.jpg</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>6</ID> 
     <type>DURATION</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">711</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>7</ID> 
     <type>STEPDESCRIPTION</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">SC</value> 
    </itemProperties> 
    <itemProperties> 
     <ID>8</ID> 
     <type>RESULTDESCRIPTION</type> 
     <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">Screen Capture - SC</value> 
    </itemProperties> 
    </resultDetailsData> 

我不得不爲價值標籤 * RESULTDESCRIPTION *的價值創造超鏈接。即「Screen Capture-SC」當我點擊它時,它應該打開文件,其值將來自標記類型的值 * LINK *。即「2013-03-25 111117-840.jpg」。

我在爲此尋找xsl代碼。有什麼建議麼。

回答

0
<?xml version="1.0" encoding="UTF-8" ?> 
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
    <xsl:output indent="yes"/> 
    <xsl:template match="/resultDetailsData"> 
     <a href="{itemProperties[type='LINK']/value}"><xsl:value-of select="itemProperties[type='RESULTDESCRIPTION']/value"/></a> 
    </xsl:template> 
</xsl:transform> 

Working example

+0

非常感謝Joepie。這幫了我很多。 – MIM 2013-03-28 22:28:59