Hi Rick,

This is what you would be looking for.

Regards
Ramon

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:jbi="xalan://org.apache.servicemix.components.xslt.XalanExtension"
  extension-element-prefixes="jbi"
  xmlns:foo="http://servicemix.apache.org/demo/";
  exclude-result-prefixes="foo"
  version="1.0">
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

  <xsl:template match="/">
      <xsl:apply-templates select="FileService[Route='Reaper']"
mode="ReaperMode"/>
  </xsl:template>

  <xsl:template match="FileService" mode="ReaperMode">
       <!-- Invoke the reaper service -->
       <jbi:invoke service="foo:trace">
           <jbi:copyProperties/>
           <!-- the message sent to foo:trace will be the result of this
next call -->
           <xsl:apply-templates select="." mode="InsertNode"/>
       </jbi:invoke>
  </xsl:template>

  <xsl:template match="FileService" mode="InsertNode">
      <FileService>
          <xsl:copy-of select="Route"/>
          <InsertedNode>2</InsertedNode>
          <xsl:copy-of select="File"/>
      </FileService>
  </xsl:template>

</xsl:stylesheet>




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, 7 April 2006 2:02 AM
To: [email protected]
Subject: problem inserting node using XSL with JBI invoke









Using the following XML:

<?xml version="1.0" encoding="UTF-8"?><FileService>
    <Route>Reaper</Route>
    <File>
        <Filename>C:\datatrans\test\trans\outbound\texty1.txt</Filename>
    </File>
    <File>
        <Filename>C:\datatrans\test\trans\outbound\texty2.txt</Filename>
    </File>
</FileService>


And this XSL stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:jbi="xalan://org.apache.servicemix.components.xslt.XalanExtension"
  extension-element-prefixes="jbi"

  xmlns:foo="http://servicemix.apache.org/demo/";
  version="1.0">
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />


  <xsl:template match="/">
    <xsl:choose>
      <!-- Invoke the reaper service -->
      <xsl:when test="FileService/Route='Reaper'">

            <xsl:for-each select="FileService/File">
                  <jbi:invoke service="foo:FileReaper">
                        <jbi:copyProperties/>
                        <xsl:copy-of select="/"/>
                  </jbi:invoke>
            </xsl:for-each>

      </xsl:when>

      <xsl:otherwise>
            <jbi:copyProperties/>
        <jbi:forward service="foo:trace"/>
      </xsl:otherwise>

    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>


I cannot seem to insert a node anywhere in the document.
Ideally I would like to insert a node just after the Route node, like so:

<?xml version="1.0" encoding="UTF-8"?>
<FileService>
    <Route>Reaper</Route>
     <InsertedNode>2</InsertedNode>
    <File>
        <Filename>C:\datatrans\test\trans\outbound\texty1.txt</Filename>
    </File>
    <File>
        <Filename>C:\datatrans\test\trans\outbound\texty10.txt</Filename>
    </File>
    <File>
        <Filename>C:\datatrans\test\trans\outbound\test1.doc</Filename>
    </File>
</FileService>


I have tried using an <xsl:element tag but to no avail. It seems to just
disrupt the output and give me errors. But the XSL as it is now does work
without my inserted node so, is it the XalanExtension not working or more
likely what is the XSL to do it?


Regards Rick

Direct Line Group Limited, registered in England

with number 2811437, registered office 3 Edridge

Road, Croydon, Surrey  CR9 1AG.  The following

companies are members of the Direct Line Group:

Direct Line Insurance plc, Direct Line Life

Insurance Company Limited, Direct Line Unit

Trusts Limited and Direct Line Financial Services

Limited, all of which are authorised and regulated

by the Financial Services Authority.  All are

members of The Royal Bank of Scotland Group.

This email is intended for the addressee only and

may contain confidential, proprietary or legally

privileged information.  If you are not the

intended recipient of this email you should

notify us immediately and delete it.  You should

not copy, print, distribute, disclose or use any

part of it.  We reserve the right to monitor and

record all electronic communications through our

networks.  We cannot accept any liability for

viruses transmitted via this e-mail once it has

left our networks.

Reply via email to