Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 2.02 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. replace a String with XSLT
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inm="http://www.inmagic.com/webpublisher/query" version='1.0'>
  4.   <xsl:output method="text" encoding="UTF-8"/>
  5.  
  6.   <xsl:preserve-space elements="*"/>
  7.   <xsl:template match="text()"></xsl:template>
  8.  
  9.   <xsl:template match="test">
  10.     <xsl:apply-templates/>
  11.  
  12.     <xsl:for-each select="testObj">
  13.       'Notes or subject' <xsl:call-template name="rem-html"><xsl:with-param name="text" select="SBS_ABSTRACT"/></xsl:call-template>
  14.     </xsl:for-each>
  15.   </xsl:template>
  16.  
  17.   <xsl:template name="rem-html">
  18.     <xsl:param name="text"/>
  19. <xsl:variable name="newtext" select="translate($text,'a','b')"/>
  20.   </xsl:template>
  21. </xsl:stylesheet>
  22.        
  23. <soap:address location="http://localhost:4434/miniwebservice"/>
  24.        
  25. <soap:address location="http://localhost:4433/miniwebservice"/>
  26.        
  27. <xsl:template match="soap:address/@location">
  28.     <xsl:attribute name="location">
  29.         <xsl:call-template name="string-replace">
  30.             <xsl:with-param name="haystack" select="current()"/>
  31.             <xsl:with-param name="search">:4434/</xsl:with-param>
  32.             <xsl:with-param name="replace">:4433/</xsl:with-param>
  33.         </xsl:call-template>
  34.     </xsl:attribute>
  35. </xsl:template>
  36.  
  37. <xsl:template match="@* | node()">
  38.     <xsl:copy>
  39.         <xsl:apply-templates select="@* | node()"/>
  40.     </xsl:copy>
  41. </xsl:template>
  42.        
  43. <?xml version="1.0" encoding="UTF-8"?>
  44. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:soap="..."
  45.     version="2.0">
  46.     <xsl:param name="newPort">4433</xsl:param>
  47.     <xsl:template match="@*|node()">
  48.         <xsl:copy>
  49.             <xsl:apply-templates select="@*|node()"/>
  50.         </xsl:copy>
  51.     </xsl:template>
  52.     <xsl:template match="soap:address/@location">
  53.         <xsl:attribute name="location">
  54.             <xsl:value-of select="replace(.,
  55.                 '^(http://[^/]*:)[0-9]{4}/',
  56.                 concat('$1',$newPort,'/'))"/>
  57.         </xsl:attribute>
  58.     </xsl:template>
  59. </xsl:stylesheet>