Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives



Larry wrote:
> In article <45c757a5$1@kcnews01>,
>  Joseph Kesselman <keshlam-nospam@c...> wrote:
> 
>> 	<a target="_blank">
>> 	  <xsl:attribute name="href">
>>   		<xsl:apply-templates select="key[text()='Location']"
>> 		 mode="getValue" /> "
>>
>> ... in other words, create the <a> element, then add an attribute that 
>> has a computed value.
> 
> ok, I got it. But now I'm having some trouble making a substitution, 
> here's some code:
> 
> <xsl:template match="dict">
>   <div>
>    <div class="name">
>     <a target="_blank">
>      <xsl:attribute name="href">
>       <xsl:apply-templates select="key[text()='Location']" mode="getAsUri"/>

That will select all child elements of dict called key, whose (implicit) 
first stretch of unmarked character data content is equal to "Location".
The template for key will then provide a value starting with the quoted 
http method, IP address and port, plus the delocalised value of the text 
content of the first element following the key, omitting to escape the 
ampersands. Is this what you meant? Presumably the element following 
such a key element does indeed contain a URI.

>      </xsl:attribute>
>      <xsl:apply-templates select="key[text()='Name']" mode="getValue" />
>      <xsl:text>&#160;</xsl:text>
>     </a>
>    </div>
>   </div>
>  </xsl:template>
>  
>  <xsl:template match="key" mode="getValue">
>   <xsl:value-of select="following-sibling::*[1]" />
>  </xsl:template>
>  
>  <xsl:template match="key" mode="getAsUri">
>   <xsl:variable name="txt">
>    <xsl:apply-templates select="." mode="getValue" />
>   </xsl:variable>
>   <xsl:text>http://127.0.0.1:8000/</xsl:text>
>   <xsl:value-of select="substring-after($txt,'file:///')"
>    disable-output-escaping="yes" />
>  </xsl:template>
>  
> It should turn:
> 
> file:///Users/etc...
> 
> to:
> 
> http://127.0.0.1:8000/Users/etc...
> 
> sadly, it doesn't work properly as I only get http://127.0.0.1:8000/ 
> without the /Users/etc... part
> 
> I can't work out what is wrong with the code

If you provided us with some sample data so that we didn't have to work 
blind it would help...

///Peter


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent