[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Am 05.06.2008 um 23:28 schrieb Julie:
- Michael M|ller-Hillebrand
</xsl:stylesheet>
Re: [xsl] searching for occurrences of unique string-value and replacing with string value of another node
Subject: Re: [xsl] searching for occurrences of unique string-value and replacing with string value of another node From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx> Date: Fri, 6 Jun 2008 12:09:23 +0200 |
Am 05.06.2008 um 23:28 schrieb Julie:
Thank you for your reply, Michael.
I put this code in but I do not get a result for the link, just ".html".
I can evaluate the xpath expressions through xmlspy, but this is a function so that doesn't work...is there any other way to evaluate what is in the key?
I don't know if that is possible. I'll give you my complete test case, which should work even with XMLSpy ;-)
- Michael M|ller-Hillebrand
XML ===
<?xml version="1.0" encoding="UTF-8"?> <PublicationContent> <File> <FileGuid>fileguid1</FileGuid> <FileShortDescription>Help 1</FileShortDescription> <ContentUnit> <CuMetadata> <BinaryType>no</BinaryType> <CuHistoryGuid>cuhistguid1</CuHistoryGuid> </CuMetadata> <CuContent> <Task> <RelatedLinks> <CuRef CuHistoryGuid="cuhistguid2">Related link text</CuRef> </RelatedLinks> </Task> </CuContent> </ContentUnit> </File> <File> <FileGuid>fileguid2</FileGuid> <FileShortDescription>Help 2</FileShortDescription> <ContentUnit> <CuMetadata> <BinaryType>no</BinaryType> <CuHistoryGuid>cuhistguid2</CuHistoryGuid> </CuMetadata> </ContentUnit> </File> </PublicationContent>
XSLT ====
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:key name="targetFile" match="File" use=".//CuHistoryGuid/text ()"/>
<xsl:template match="RelatedLinks/CuRef"> <a class="old" href="{@CuHistoryGuid}.html"> <xsl:apply-templates/> </a> <a class="new" href="{key('targetFile', @CuHistoryGuid)/ FileGuid/text()}.html"> <xsl:apply-templates/> </a> </xsl:template>
<xsl:template match="@*|node()"> <xsl:apply-templates select="@*|node()"/> </xsl:template>
</xsl:stylesheet>
Result ======
<?xml version="1.0" encoding="UTF-8"?> <a class="old" href="cuhistguid2.html"/> <a class="new" href="fileguid2.html"/>
-- _______________________________________________________________ Michael M|ller-Hillebrand: Dokumentations-Technologie Adobe Certified Expert, FrameMaker Lvsungen und Training, FrameScript, XML/XSL, Unicode <http://cap-studio.de/> -- Tel. +49 (9131) 28747
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] searching for occurrences, Julie | Thread | Re: [xsl] searching for occurrences, Julie |
RE: [xsl] Value of attribute starts, Pankaj Chaturvedi | Date | Re: [xsl] XQuery basics, Liam Quin |
Month |