Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 7th, 2011, 07:26 PM
Registered User
 
Join Date: Mar 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

just to be complete this is what I wound up with:
in this version I took out the call to the java function and replaced it with
constantsXsltMap.xml

Code:
<?xml version="1.0" encoding="utf-8"?>
    <map>
      <entry key="53bfdc0c8b9341688a520134b1098b26">ValueX</entry>

     <entry key="5af8a532523c4c6e9f9344c0827391ee">ValueY</entry>
       <!-- default entry must be last in document -->
  <default>some-default-i-dont-use-this</default>
    </map>
Code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions"
  xmlns:saxon="http://saxon.sf.net/" xmlns:guid="java:com.me.ConstantsMap" exclude-result-prefixes="saxon guid"
>

  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
  <xsl:param name="map-file" select="string('constantsXsltMap.xml')" />
  <xsl:variable name="map-doc" select="document($map-file)" />
 <xsl:variable name="default" select="$map-doc/map/default[1]" />
 
  <xsl:key name="map" match="/map/entry" use="@key" />
  
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>


  <xsl:template match="sXmlParameters">
    <sXmlParameters>
      <xsl:apply-templates select="saxon:parse(.)" />
    </sXmlParameters>
  </xsl:template>


  <xsl:template match="node()[ends-with(local-name(), 'Result')]">
    <xsl:element name="{local-name()}" namespace="{namespace-uri()}">
      <xsl:apply-templates select="saxon:parse(.)" />
    </xsl:element>
  </xsl:template>

<xsl:template match="*/text()">
    <xsl:variable name="raw-value" select="." />
      <xsl:for-each select="$map-doc">
        <xsl:value-of select="(key('map', $raw-value)|$raw-value)[1]" />
      </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>
for the mapping portion I referred to :
XSLT: Efficient mapping of two large lists

My mapping varies slightly in that I don't use the default, if there is no
matching key in the map I just leave the original value.

Sam, I tried your solution to get rid of the xmlns="", but I couldn't get it to
work. Then I went back and took a second look at the input, turns out the
xmlns="" is in there. I got the input file out of SoapUI, maybe its putting it there. In any event I am satisfied and grateful!
Code:
<RetrieveResultResult xmlns="">
Thanks for all your help





Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable substitution in logging.properties Gap_Tooth Apache Tomcat 0 July 21st, 2008 02:50 PM
Correct my xslt for data substitution asap XSLT 0 July 29th, 2006 03:42 PM
How to copy text MICZ Pro VB 6 5 October 29th, 2004 09:57 AM
copy xml to xml (with java script) Umen XML 4 September 14th, 2004 06:51 AM
Substitution for CodeContextObject MKri VB.NET 2002/2003 Basics 0 August 20th, 2004 03:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.