2013-10-07 4 views
0

I tried a lot to see if any suggestion/answer would satisfy my requirement but could not find any.Xslt : <a href="" /> in xslt during runtime

I have an Xml file which I am using to get an output Html file using XslTransform API and an Xslt stylesheet.

My xml file has a rootnode which will have two attributes - HyperlinkDisplayText and HyperlinkValue. This xml file is generated at runtime. So, the values of these attributes are not known at compile time.

My requirement is that the html output should display a hyperlink whose display text needs to be taken from the value of 'HyperlinkDisplayText' and the hyperlink value needs to be taken from the value of "HyperlinkValue'.

For example,

<RootNode HyperlinkDisplayText="Google" HyperlinkValue="https://www.google.com/" /> 

This needs to be appears as Google의 innertext 값을 채 웁니다.

이렇게하려면 내 xslt에서 여러 가지를 시도했습니다. 다음은 내 xslt 파일에서 시도한 스냅 샷입니다. -

<xsl:choose> 
    <xsl:when test="@HyperlinkDisplayText and @HyperlinkValue"> 
    <h4 style="font-family: arial" align='center'> 
     <a href="{./@HyperlinkValue}">@HyperlinkDisplayText</a> 
    </h4> 
    </xsl:when> 
    <xsl:otherwise> 
    </xsl:otherwise> 
</xsl:choose> 

작동하지 않습니다. 어떤 도움을 주셔서 감사합니다.

감사합니다, kvk938

답변

2

변경 <a href="{@HyperlinkValue}"><xsl:value-of select="@HyperlinkDisplayText"/></a>-<a href="{./@HyperlinkValue}">@HyperlinkDisplayText</a>. 이것은 컨텍스트 노드가 RootNode 요소라고 가정합니다.

+0

고맙습니다. 괜찮 았어. – kvk938