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

What's the correct way to output an element to the res

Subject: What's the correct way to output an element to the result tree
From: Peter Lerche <peter@xxxxxxxxxxxxxx>
Date: Wed, 29 Sep 2004 14:20:33 +0200
peter lerche
Hi,

I was looking through this mailing-list trying to find an answer. However I 
found a question (posted in 2001) which addressed my problem but no answer. 
Therefore I am quoting the original question hoping somebody has the answer.

-QUOTE-
What's the correct way to output an element to the result tree from within
the code of an extension element (or function)?

As a dummy example, let's say I want to write a Javascript extension element
(using the Xalan-Java processor) to output a <p> tag, then process
the child elements of the context node, then output a </p> tag.  The code
I've got at the moment is

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:lxslt="http://xml.apache.org/xslt";
                xmlns:my="MyNamespace"
                extension-element-prefixes="my"
                version="1.0">
                
  <lxslt:component prefix="my" elements="para">
  <lxslt:script lang="javascript">
    <![CDATA[

      function para(xslContext,thisElement) {
        xslContext.outputToResultTree(xslContext.getStylesheet(),"<p>");
        
        xslTrans = xslContext.getTransformer();
        xslTrans.executeChildTemplates(thisElement,
           xslContext.getContextNode(),
           xslContext.getMode(),
           true
        );
        
        xslContext.outputToResultTree(xslContext.getStylesheet(),"</p>");
        
        return null;
      }
    ]]>
  </lxslt:script>
  </lxslt:component>

  <xsl:template match="/">
    <my:para>
      This is a paragraph.
    </my:para>
  </xsl:template>
</xsl:stylesheet>

Of course, this isn't right.  I don't want to output the text strings '<p>'
and '</p>'; I want to output an element node <p>.
-UNQUOTE-
-- 
Med venlig hilsen / Yours sincerely 
 
Peter
http://easyspeedy.com 
_______________________________________ 
European Dedicated Server Hosting 
Extremely low prices, secure, and reliable
Linux and BSD distributions only 
_______________________________________

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.