[jdom-interest] Creating a pure text file using XSL

Jay Burgess jburgess at delanotech.com
Thu Nov 8 13:51:58 PST 2001


I'd actually already tried that one as well.  I get another stack trace, 
but the primary error is:

     [java] javax.xml.transform.TransformerException: xsl:value-of is not 
allowed in this position in the stylesheet!

On a secondary note, realize that the <p></p> is just an arbitrary tag pair 
that I picked. I can use <p></p>, <url></url>, 
<EnglandDanAndJohnFordColey></EnglandDanAndJohnFordColey>, etc., and they 
will work.

Jay

-----Original Message-----
From: Brett McLaughlin [mailto:brett at newInstance.com]
Sent: Thursday, November 08, 2001 3:36 PM
To: jdom-interest at jdom.org; Jay Burgess
Subject: Re: [jdom-interest] Creating a pure text file using XSL


Try replacing <p> with <xsl:text> and see what happens.


---
Brett McLaughlin            <http://www.newInstance.com>
Lutris Technologies         <http://www.lutris.com>
Author, "Java and XML" <http://www.oreilly.com/catalog/javaxml2>
----- Original Message -----
From: "Jay Burgess" <jburgess at delanotech.com>
To: <jdom-interest at jdom.org>
Sent: Thursday, November 08, 2001 3:07 PM
Subject: [jdom-interest] Creating a pure text file using XSL


 > I've asked this question on an XSL list, and now it's not clear to me
 > whether it's an XSL issue, or an issue with my use of JDOM.  Here goes:
 >
 > I've got the following code snippet in my .XSL file:
 >
 > <?xml version="1.0" encoding="UTF-8"?>
 > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
 > <xsl:output method="text" indent="yes" omit-xml-declaration="yes" />
 > <xsl:param name="FILENAME"/>
 > <xsl:template match="page">
 >      <xsl:choose>
 >          <xsl:when test="$FILENAME != ''">
 >              <p>http://YOURMACHINE/<xsl:value-of select="$FILENAME"/></p>
 >          </xsl:when>
 >          <xsl:otherwise>...
 >
 > It outputs something like:
 >
 > <p>http://YOURMACHINE/page1.html</p>
 > <p>http://YOURMACHINE/page2.html</p>
 > <p>http://YOURMACHINE/page3.html</p>
 >
 > But what I really want is just a plain text file containing one URL string
 > per line, without the <p></p>, like:
 >
 > http://YOURMACHINE/page1.html
 > http://YOURMACHINE/page2.html
 > http://YOURMACHINE/page3.html
 >
 > (Again, these aren't HREF's. They're simply URL strings, with no XML/HTML
 > markup around them.)
 >
 > Is this possible with XSL?
 >
 > Here's the relevant Java code using JDOM, in case that's where I'm doing
 > something wrong:
 >
 >            JDOMSource source = new JDOMSource(new
Document(element.detach()));
 >            JDOMResult result = new JDOMResult();
 >            XMLOutputter outputter = new XMLOutputter("    ", true);
 >            outputter.setTextNormalize(true);
 >            outputter.setOmitDeclaration(true);
 >            outputter.setNewlines(false);
 >            transformer.setParameter("FILENAME", fileName);
 >            transformer.transform(source, result);
 >            outputter.output(result.getDocument(), packageFile);
 >
 > Finally, for reference, if I remove the <p></p> in my XSL file, I get a
 > stack trace, which starts off like:
 >
 >       [java] javax.xml.transform.TransformerException
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transformNode(Tr
 > ansformerImpl.java:1151)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:590)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:1037)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:1015)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.main(Unknown Source)
 >       [java] ---------
 >       [java] java.util.EmptyStackException
 >       [java]     at java.util.Stack.peek(Stack.java:82)
 >       [java]     at
org.jdom.input.SAXHandler.characters(SAXHandler.java:483)
 >       [java]     at
 > org.xml.sax.helpers.XMLFilterImpl.characters(XMLFilterImpl.ja
 > va:614)
 >       [java]     at
 > org.apache.xalan.transformer.ResultTreeHandler.characters(Res
 > ultTreeHandler.java:471)
 >       [java]     at
 > org.apache.xalan.templates.ElemTextLiteral.execute(ElemTextLi
 > teral.java:256)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.executeChildTemp
 > lates(TransformerImpl.java:2096)
 >       [java]     at
 > org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java
 > :164)
 >       [java]     at
 > org.apache.xalan.templates.ElemApplyTemplates.transformSelect
 > edNodes(ElemApplyTemplates.java:423)
 >       [java]     at
 > org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApp
 > lyTemplates.java:226)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.executeChildTemp
 > lates(TransformerImpl.java:2096)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.applyTemplateToN
 > ode(TransformerImpl.java:1927)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transformNode(Tr
 > ansformerImpl.java:1120)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:590)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:1037)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:1015)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.main(Unknown Source)
 >       [java] javax.xml.transform.TransformerException
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transformNode(Tr
 > ansformerImpl.java:1151)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:590)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:1037)
 >       [java]     at
 > org.apache.xalan.transformer.TransformerImpl.transform(Transf
 > ormerImpl.java:1015)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.parse(Unknown Source)
 >       [java]     at XMLConfig.main(Unknown Source)
 >       [java] ---------
 >       [java] java.util.EmptyStackException
 >       [java]     at java.util.Stack.peek(Stack.java:82)
 >       [java]     at
org.jdom.input.SAXHandler.characters(SAXHandler.java:483)
 >       [java]     at
 > org.xml.sax.helpers.XMLFilterImpl.characters(XMLFilterImpl.ja
 > va:614)
 >
 > Thanks.
 >
 > Jay
 >




More information about the jdom-interest mailing list