Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: and xsl >Thread Next - Re: and xsl 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> </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 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
