2013-03-28 8 views
0

Я использую следующий xml и хочу отображать в HTML с помощью xslt.Как создать гиперссылку в 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

Смежные вопросы