Re: Extension element content

Nathan Nadeau <[email protected]> Tue, 12 Apr 2011 13:14:57 -0400
Newsgroups gmane.text.xml.xalan.java.user
Organization Gleim Publications
Message-ID <[email protected]>
Ken, I had to do a bit of hunting in the Xalan API but I found the 
TransformerImpl.transformToString() method:

The following snippet worked for me:
-------------------------
String elemValue = "";
TransformerImpl transf = XSLPC.getTransformer();
try{
   elemValue = transf.transformToString(EEC);
} catch (TransformerException e){}
-------------------------

Nathan

[email protected] wrote:
> Sorry about the dumb question, but I'm struggling with an extension 
> element and getting its content.
>
> I'm running Xalan-J 2.7.1, and am trying to implement an extension 
> element like
>
> <my:element attrib1="foo" attrib2="bar">text1<xsl:value-of 
> select="$var"/>text2</my:element>
>
> My java looks like
>
> public void element(XSLProcessorContext XSLPC, ElemExtensionCall EEC) {
>     String foo = EEC.getAttribute("foo", 
> XSLPC.getContextNode(),XSLPC.getTransformer()); // works fine
>     String bar = 
> EEC.getAttribute("bar",XSLPC.getContextNode(),XSLPC.getTransformer()); 
> // works fine
>     // get content, somehow
> }
>
> So far, in order to get to the content, preferably with the 
> xsl:value-of already executed, I've tried:
> EEC.getFirstChild() --> ElemTemplateElement error: Function not 
> supported!
> EEC.getParentNode() --> ElemTemplateElement error: Function not 
> supported!
> EEC.getFirstChildElem() --> ElemTemplateElement error: Function not 
> supported!
> EEC.getChildNodes().item(0) --> ElemTemplateElement error: Function 
> not supported!
> XSLPC.getTransformer.getCurrentElement.getParentNode() --> 
> ElemTemplateElement error: Function not supported!
>
> So, this has to be brain-dead simple, but I've looked through the 
> archives and haven't been able to dig up the solution.
>
> Thanks,
> Ken

-- 
Nathan Nadeau
[email protected]
Software Development
Gleim Publications, Inc.
http://www.gleim.com