You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Patrick Moore <pa...@rioport.com> on 2001/02/21 22:58:54 UTC

RE: problem with namespaces .. [MORE INFO- looks like a bug]...us ing the SimpleTransform example + e xamples

This appears to be a bug:

            <PLAYTIME>
                <rioport:min2sec>
                    <xsl:value-of select="TRACK_PLAYTIME/text()" />
                </rioport:min2sec>
            </PLAYTIME>

In the min2sec code I print out the child nodes of the Context node as
returned by XSLProcessorContext.getContextNode() [see code snippet below].
The child nodes printed out are the TRACK_PLAYTIME's parent's child nodes. I
tried using xsl:copy-of and got the same result.

for ( node = context.getContextNode().getFirstChild();
	  node != null; node = node.getNextSibling()) {
System.out.println(node.getClass().getName() );
	if ( node.getNodeType() == Node.TEXT_NODE ) {
System.out.println("value:"+node.getNodeValue());
	}
}

-Patrick Moore-
> -----Original Message-----
> From: Patrick Moore [mailto:patrickm@rioport.com]
> Sent: Wednesday, February 21, 2001 11:37 AM
> To: 'xalan-dev@xml.apache.org'
> Subject: RE: problem with namespaces using the 
> SimpleTransform example +
> e xam ples
> 
> 
> Hi Scott --
> 
> The "No time supplied" Message is a sign of the problem. If 
> you remove the
> <rioport:min2sec> elements the resulting xml document shows a 
> value for
> <PLAYTIME> (see attached file). But when the tags are there 
> the textnodes do
> not contain anything except whitespace.
> 
> Thanks for whatever help you can supply.
> 
> -Patrick Moore-
> 
> P.S. using the xerces.jar that came with xalan...
> 
> Sample output when USING rioport extensions (what happened to
> non-whitespace?):
> org.apache.xalan.stree.TextImpl
> value:
> 
> org.apache.xalan.stree.ElementImpl 
> org.apache.xalan.stree.TextImpl
> value:
> 
> org.apache.xalan.stree.ElementImpl 
> org.apache.xalan.stree.TextImpl 
> value:
> 
> org.apache.xalan.stree.ElementImpl 
> org.apache.xalan.stree.TextImpl 
> value:
> 
> org.apache.xalan.stree.ElementImpl 
> org.apache.xalan.stree.TextImpl 
> value:
> 
> org.apache.xalan.stree.ElementImpl
> org.apache.xalan.stree.TextImpl 
> value:
> 
> org.apache.xalan.stree.ElementImpl 
> org.apache.xalan.stree.TextImpl 
> value:
> 
> org.apache.xalan.stree.ElementImpl 
> org.apache.xalan.stree.TextImpl 
> value:
> 
> org.apache.xalan.stree.ElementImpl 
> org.apache.xalan.stree.TextImpl 
> value:
> 
> HELLLO! min2sec: 
> file:///C:/ATG/Dynamo5.1/CFS/lib/xml/bmg.xsl; Line 85;
> Column 34; javax.xml.transform.TransformerException 	at
> org.apache.xalan.transformer.TransformerImpl.transformNode(Tra
> nsformerImpl.j
> ava:1212) 	at
> org.apache.xalan.transformer.TransformerImpl.run(TransformerIm
> pl.java:2894)
> at java.lang.Thread.run(Thread.java:484) --------- 
> ; SystemID: file:///C:/ATG/Dynamo5.1/CFS/lib/xml/bmg.xsl; Line#: 85;
> Column#: 34 
> ; SystemID: file:///C:/ATG/Dynamo5.1/CFS/lib/xml/bmg.xsl; Line#: 85;
> Column#: 34
> 
> 
> > -----Original Message-----
> > From: Scott_Boag@lotus.com [mailto:Scott_Boag@lotus.com]
> > Sent: Wednesday, February 21, 2001 11:08 AM
> > To: xalan-dev@xml.apache.org
> > Subject: Re: problem with namespaces using the 
> > SimpleTransform example +
> > exam ples
> > 
> > 
> > 
> > When I run this (with DTD decl commented out) from the 
> > command line I get a
> > "no time supplied" error from the extension.  Since 
> > SimpleTransform only
> > does a stream transformation, this should have nothing to do 
> > with the DOM.
> > I'm frankly confused as to what the problem is.  If you need 
> > me to look at
> > this further, please supply a minimal *complete* example 
> > where the problem
> > can be reproduced.
> > 
> > -scott
> > 
> > 
> > 
> > 
> >                                                               
> >                                                      
> >                     Patrick Moore                             
> >                                                      
> >                     <patrickm@rio        To:     
> > "'xalan-dev@xml.apache.org'" <xa...@xml.apache.org>           
> >                     port.com>            cc:     (bcc: Scott 
> > Boag/CAM/Lotus)                                       
> >                                          Subject:     problem 
> > with namespaces using the SimpleTransform example +  
> >                     02/20/2001           exam    ples         
> >                                                      
> >                     08:12 PM                                  
> >                                                      
> >                     Please                                    
> >                                                      
> >                     respond to                                
> >                                                      
> >                     xalan-dev                                 
> >                                                      
> >                                                               
> >                                                      
> >                                                               
> >                                                      
> > 
> > 
> > 
> > 
> > Sorry forgot the example files:
> > 
> > > -----Original Message-----
> > > From: Patrick Moore [mailto:patrickm@rioport.com]
> > > Sent: Tuesday, February 20, 2001 5:10 PM
> > > To: 'xalan-dev@xml.apache.org'
> > > Subject: problem with namespaces using the SimpleTransform example
> > >
> > >
> > > I am using the SimpleTransform sample and I am having this
> > > problem. The
> > > annoying thing is that I tested this code using the D-07 beta
> > > release and it
> > > worked. Also I do not see how to set Namespace-awareness in 
> > any of the
> > > classes used by SimpleTransform.
> 
> 

jsp xsl problem

Posted by "陳照東) <alex@erp.ncu.edu.tw>" <Alex>.
below is my jsp code try to transform the xml to string by xsl, i use
Xalan2, but it cant work.......please help me...

<%@ page language="java" %>
<%@ page import="java.io.*"%>
<%@ page import="org.apache.xalan.xpath.xml.XMLParserLiaison"%>
<%@ page import="org.apache.xalan.xslt.*"%>
<%@ page import="org.apache.xerces.framework.XMLParser"%>
<%@ page import="org.apache.xerces.parsers.DOMParser"%>
<%@ page import="org.w3c.dom.Node"%>

<%
XSLTProcessor xsltproc=XSLTProcessorFactory.getProcessor(new
XMLParserLiaison());

StringWriter stringwriter=new StringWriter();
String xmlname="stamps.xml";
String xslname="stampTest.xsl";
String filename1=application.getRealPath("/xml/"+xmlname);
String filename2=application.getRealPath("/xml/"+xslname);
FileReader filereader=new FileReader(filename1);

XSLTInputSource xsltinputsource=new XSLTInputSource(filereader);
XSLTInputSource xsltinputsource1=new XSLTInputSource(filename2);
XSLTResultTarget xsltresulttarget=new XSLTResultTarget(stringwriter);
xsltproc.process(xsltinputsource,xsltinputsource1,xsltresulttarget);
String output=stringwriter.toString();
%>

<html>
<body>
test
</body>
</html>

****************************
but it get error like below:

: SAX Exception
javax.xml.transform.TransformerException: SAX Exception
java.lang.Throwable() java.lang.Exception()
org.xml.sax.SAXException(java.lang.Exception) void
org.apache.xalan.xslt.XSLTEngineImpl.error(int, java.lang.Object [],
 java.lang.Exception) void org.apache.xalan.xslt.XSLTEngineImpl.error(int,
java.lang.Exception) void
org.apache.xalan.xslt.XSLTEngineImpl.process(org.apache.xalan.xslt.XSLTInput
Source, org.apache.xalan.xslt.XSLTInputSource,

why???  i use Xalan2
what should  i do?????

Alex





Re: problem with namespaces .. [MORE INFO- looks like a bug]...using the SimpleTransform example + e xamples

Posted by Gary L Peskin <ga...@firstech.com>.
Patrick Moore wrote:
> 
> This appears to be a bug:
> 
>             <PLAYTIME>
>                 <rioport:min2sec>
>                     <xsl:value-of select="TRACK_PLAYTIME/text()" />
>                 </rioport:min2sec>
>             </PLAYTIME>
> 
> In the min2sec code I print out the child nodes of the Context node as
> returned by XSLProcessorContext.getContextNode() [see code snippet below].
> The child nodes printed out are the TRACK_PLAYTIME's parent's child nodes. I
> tried using xsl:copy-of and got the same result.
> 
> for ( node = context.getContextNode().getFirstChild();
>           node != null; node = node.getNextSibling()) {
> System.out.println(node.getClass().getName() );
>         if ( node.getNodeType() == Node.TEXT_NODE ) {
> System.out.println("value:"+node.getNodeValue());
>         }
> }

This is what I was alluding to in my earlier message.  It's not a Xalan
bug.  The context node for a template comes from the current node for
the template.  The current node for the template is basically the node
which caused the template to be chosen.  In your case, that is the
<TRACK> node.  So, you'll get all of the children of the <TRACK> node. 
The text nodes that you're seeing with just a newline for content are
the whitespace nodes between the various elements that are the children
of <TRACK>.

If I were you, I'd shelve the extension element and create an extension
function, passing the text time, like this:

  <PLAYTIME>
    <xsl:value-of select="rioport:min2sec(string(TRACK_PLAYTIME))"/>
  </PLAYTIME>

I think this is what you want to do.

Gary