[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: searching for occurrences of unique string-value a

Subject: Re: 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
Re:  searching for occurrences of unique string-value a
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.