OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: To Buy, or to Build? That is the q...


Hadn't seen an answer to this one yet so I thought I would embarass myself
and give it a whack.


>and I want to go through my entire xml and find all the references of
#{Id}#, and then find the >Node with that id, and replace the references
with the name of the found node, so that for >example,  the third line would


Well this obviously skips some of the important details about copying the
existing nodes and just handles the replacement of the text (which I assume
was the problem)-- and it is definitely not optimized for speed, and it
doesn't take many things into consideration, and...  That being said:

  <Node Id="2001" Name="Statement1">
       <Parameter Key="Line 1" Value="use #2002# here" />
  <Node Id="2002" Name="Statement2">
       <Parameter Key="Line 1" Value="a" />


<?xml version="1.0"?>

  <!--Set the output method -->
  <xsl:output method="text" encoding="UTF-8" indent="yes"/>

  <xsl:template match="/">
    <xsl:for-each select="//Parameter/@Value">
      <xsl:if test="contains(current(), '#')">
        <xsl:variable name="temp" select="substring-after(current(), '#')"/>
        <xsl:variable name="leading" select="substring-before(current(),
        <xsl:variable name="trailing" select="substring-after($temp, '#')"/>
        <xsl:variable name="refId" select="substring-before($temp, '#')"/>
        <xsl:variable name="refValue" select="//Node[@Id=$refId]/@Name"/>
        <xsl:value-of select="concat($leading, ' ', $refValue, ' ',


I obviously changed a little in your sample instance and the output of this
stylesheet leaves much to the imagination (it is only the new Value
attribute text).  Also I will point you to the much better list [1] for
these questions and the FAQ [2] as I saw you said you recently purchased a
book and figure you will need it sooner or later (I know I have).

[1] http://www.mulberrytech.com/xsl/xsl-list/index.html
[2] http://www.dpawson.co.uk/xsl/xslfaq.html

Good Luck!
Jeff Rafter