<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>xalan-j-users@xml.apache.org Archives</title>
<link rel="self" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/?format=atom"/>
<link href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/"/>
<id>http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/</id>
<updated>2009-12-09T20:29:16Z</updated>
<entry>
<title>Re: How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>keshlam@us.ibm.com</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3cOF1BA937ED.8AB44C9D-ON8525767F.0057D948-8525767F.0058D9F0@lotus.com%3e"/>
<id>urn:uuid:%3cOF1BA937ED-8AB44C9D-ON8525767F-0057D948-8525767F-0058D9F0@lotus-com%3e</id>
<updated>2009-12-01T16:13:12Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
&gt; So it seems to mean a new XSLT 2.0 processor has been released about
&gt; two weeks ago?
&gt; 
&gt; http://www.ibm.com/common/ssi/rep_ca/1/897/ENUS209-391/ENUS209-391.PDF

Yes, though it's only available as part of the Websphere environment.

(Don't bother asking me whether it will be available through other 
channels. I honestly don't know, and if I did I couldn't say so anyway.)

______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
http://www.ovff.org/pegasus/songs/threes-rev-11.html)


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3c20091201154841.GC2584@wladimir%3e"/>
<id>urn:uuid:%3c20091201154841-GC2584@wladimir%3e</id>
<updated>2009-12-01T15:48:41Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
keshlam@us.ibm.com schrieb am 01.12.2009 um 09:13:46 (-0500):
&gt; 
&gt; It means I've been involved with IBM's new XML Feature Pack for
&gt; Websphere, which supports the 2.0 versions; hence my carelessly
&gt; suggesting a 2.0-only solution.

So it seems to mean a new XSLT 2.0 processor has been released about
two weeks ago?

http://www.ibm.com/common/ssi/rep_ca/1/897/ENUS209-391/ENUS209-391.PDF

-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Error in output when xmlns attribute is present</title>
<author><name>keshlam@us.ibm.com</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3cOF8E854278.1EBF7EA0-ON8525767F.004FE281-8525767F.00501CFA@lotus.com%3e"/>
<id>urn:uuid:%3cOF8E854278-1EBF7EA0-ON8525767F-004FE281-8525767F-00501CFA@lotus-com%3e</id>
<updated>2009-12-01T14:37:45Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
The xmlns attribute sets the default namespace. XSLT is 
namespace-sensitive; to match namespace-qualified elements and attributes 
you must match the namespaces as well (which means using prefixes in your 
XSLT even though you used the default in the instance document, since XSLT 
1.0 has no ability to specify a default namespace for its match/select 
patterns).


______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
http://www.ovff.org/pegasus/songs/threes-rev-11.html)

</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>keshlam@us.ibm.com</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3cOF008FA9C0.39EB74FF-ON8525767F.004D6B49-8525767F.004DEAC6@lotus.com%3e"/>
<id>urn:uuid:%3cOF008FA9C0-39EB74FF-ON8525767F-004D6B49-8525767F-004DEAC6@lotus-com%3e</id>
<updated>2009-12-01T14:13:46Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
&gt; Does that mean Xalan's going 2.0?

It means I've been involved with IBM's new XML Feature Pack for Websphere, 
which supports the 2.0 versions; hence my carelessly suggesting a 2.0-only 
solution.

</pre>
</div>
</content>
</entry>
<entry>
<title>Error in output when xmlns attribute is present</title>
<author><name>=?ISO-8859-1?Q?Gustavo_de_S=E1_Carvalho_Honorato?= &lt;gustavohonorato@gmail.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3ccd77cd4e0912010612q9bafb18o15d6f2ad03de7d74@mail.gmail.com%3e"/>
<id>urn:uuid:%3ccd77cd4e0912010612q9bafb18o15d6f2ad03de7d74@mail-gmail-com%3e</id>
<updated>2009-12-01T14:12:03Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi all,

I'm having some problems using Xalan to make XSLT using JAXP Java API. When
xmlns attribute is not present in root element of the input xml, the output
is fine. When xmlns is present, Xalan is generating an empty output. Is
there any issue regarding this? I've been searching all over the
documentation and I could not find anything.

Thanks in advance,
Gustavo Honorato


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3c20091201140155.GB2584@wladimir%3e"/>
<id>urn:uuid:%3c20091201140155-GB2584@wladimir%3e</id>
<updated>2009-12-01T14:01:55Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
keshlam@us.ibm.com schrieb am 30.11.2009 um 11:46:31 (-0500):
&gt; &gt; Pretty sure XPath 1.0 [1] only allows foo:* wildcards (but not
&gt; &gt; *:foo).
&gt; 
&gt; ... Right. Sorry; too much time working on 2.0 recently.

Does that mean Xalan's going 2.0?

-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: xml with dots in tags</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3c20091201135803.GA2584@wladimir%3e"/>
<id>urn:uuid:%3c20091201135803-GA2584@wladimir%3e</id>
<updated>2009-12-01T13:58:03Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Marc Ende schrieb am 01.12.2009 um 14:38:39 (+0100):
&gt; Hi Michael,
&gt; 
&gt; thanks for your help. It seems that the issue doesn't relate to the
&gt; '.'. But I have no further ideas. Can you have a look on this
&gt; stylesheet and the input xml. I thought that the issue that the
&gt; xsd:value-of doesn't provide any data relates to the dots. But now I
&gt; know that's not the case.
&gt; 
&gt; Maybe you can give me a hint. I've spend about 8 hours and haven't
&gt; found any point how I can resolve this issue.

Marc,

please reply to the list, not privately. (I know you did it
inadvertently, as this list does not set the Reply-To header
as it should.)

As to the issue at hand, it is dead simple. Your input is in a
namespace, and your stylesheet doesn't take that into account.
Read up about XML namespaces to save you from further harm and
waste of time. XML namespaces are trivial to understand, but a
bit annoying due to excessive URI verbosity.

&lt;xmeldit.datenlieferung.1100 fassung="2009-07-31" version="1.5"
  produkt="OK.EWO" produkthersteller="AKDB" produktversion="05.70.10"
  xmlns="http://www.osci.de/xmeld15"
  xmlns:xoev="www.deutschland-online.de/XOEV"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.osci.de/xmeld15
  S:\e01entw_eGov\XMELD\XMELD1~1.5\xmeld-nachrichten-xmeldit.xsd"&gt;
  [...]

The URI for xoev does not look like a valid URI.

&lt;xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  [...]

Your stylesheet should declare all namespaces that are needed and
use them accordingly.

&lt;xsl:transform version="1.0"
  xmlns="http://www.osci.de/xmeld15"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

Plus, you *absolutely* need to learn about "push" vs "pull" approach.
You're using the pull approach, which is only suitable for the most
trivial tasks. The one you have looks like a job for a push approach.
The "modified identity template" approach I mentioned is a push
approach.

Good luck,
-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: xml with dots in tags</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3c20091201131941.GD3428@wladimir%3e"/>
<id>urn:uuid:%3c20091201131941-GD3428@wladimir%3e</id>
<updated>2009-12-01T13:19:42Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Marc Ende schrieb am 01.12.2009 um 10:39:20 (+0100):

&gt; But within the source-xml they've got '.' in the tags. For example:
&gt; 
&gt; &lt;root.element&gt;
&gt;   &lt;test.element&gt;Hello World&lt;/test.element&gt;
&gt; &lt;/root.element&gt;

There's nothing unusual at all with that.

&gt; If I try to access the value with such xslt I got nothing:
&gt; 
&gt; &lt;xsl:template match="/"&gt;
&gt;   &lt;test&gt;&lt;xsl:value-of select="root.element/test.element"/&gt;&lt;/test&gt;
&gt; &lt;/xsl:template&gt;

Works fine for me. Did you apply the stylesheet to the correct input?

&gt; I tried to escape the dots in the select with '\.' but that doesn't
&gt; work.

It doesn't because you must not prefix the dot with a backslash. XPath
does not follow the same rules as grep, or the shell, or Perl.

&gt; In XPath there was the . mentioned as a replacement for a character.
&gt; So it should also work on '.' I think.

Don't know what you mean, but "." is the current context node.

&gt; By the way. Is there any way to 'copy' parts of one xml in the other
&gt; xml within the transformation?
&gt; It would be helpful if there are parts which doesn't need to
&gt; transformed (just copied).

I think you're looking for the standard pattern called "modified
identity transform". Googling for that will teach you the concept.
It's not difficult and really practical.

Best,
-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>xml with dots in tags</title>
<author><name>Marc Ende &lt;mlists@e-beyond.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200912.mbox/%3c4B14E448.6020809@e-beyond.de%3e"/>
<id>urn:uuid:%3c4B14E448-6020809@e-beyond-de%3e</id>
<updated>2009-12-01T09:39:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi,

since yesterday I've got a project on xslt transformation from one xml 
to another schema.
But within the source-xml they've got '.' in the tags. For example:

&lt;root.element&gt;
   &lt;test.element&gt;Hello World&lt;/test.element&gt;
&lt;/root.element&gt;

If I try to access the value with such xslt I got nothing:

&lt;xsl:template match="/"&gt;
   &lt;test&gt;&lt;xsl:value-of select="root.element/test.element"/&gt;&lt;/test&gt;
&lt;/xsl:template&gt;

It I try it without dot's:
&lt;root&gt;
&lt;test&gt;Hello World&lt;/test&gt;
&lt;/root&gt;
and
&lt;xsl:template match="/"&gt;
   &lt;test&gt;&lt;xsl:value-of select="root/test"/&gt;&lt;/test&gt;
&lt;/xsl:template&gt;

Everything works fine. I tried to escape the dots in the select with 
'\.' but that doesn't
work. In XPath there was the . mentioned as a replacement for a 
character. So it should
also work on '.' I think.

Does anybody has an idea?

By the way. Is there any way to 'copy' parts of one xml in the other xml 
within the transformation?
It would be helpful if there are parts which doesn't need to transformed 
(just copied).

Thanks for your help!

Marc


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>keshlam@us.ibm.com</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cOFA90E49B1.27A00A6C-ON8525767E.005B8DB6-8525767E.005BE716@lotus.com%3e"/>
<id>urn:uuid:%3cOFA90E49B1-27A00A6C-ON8525767E-005B8DB6-8525767E-005BE716@lotus-com%3e</id>
<updated>2009-11-30T16:46:31Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
&gt; Pretty sure XPath 1.0 [1] only allows foo:* wildcards (but not *:foo).

... Right. Sorry; too much time working on 2.0 recently.

The 1.0 equivalent would indeed be 
        *[localname()="foo"]

And, of course, if you want to ignore the name entirely, just matching on 
* will do that.

NOTE: Since the namespace is part of the semantics (meaning) of the 
document, ignoring it is usually an indicator of bad design (unless you're 
working in 2.0 and manipulating schema types rather than names). Think 
long and hard about what you're really trying to do and whether this is 
the best way to do it.


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>Michael Glavassevich &lt;mrglavas@ca.ibm.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cOFD2A8E69A.0104BB88-ON8525767E.005AFAFC-8525767E.005B5908@ca.ibm.com%3e"/>
<id>urn:uuid:%3cOFD2A8E69A-0104BB88-ON8525767E-005AFAFC-8525767E-005B5908@ca-ibm-com%3e</id>
<updated>2009-11-30T16:37:45Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Content-type: text/plain; charset=US-ASCII

keshlam@us.ibm.com wrote on 11/30/2009 11:28:36 AM:

&gt; &gt; As we have xs:any in xerces for any namespace usage , how do I
&gt; &gt; achieve in xslt ? I could not find any construct in xsl as we have
&gt; &gt; in schema language.
&gt;
&gt; XSLT 1.0 and XPath 1.0 are not schema-aware. (That was added in the
&gt; 2.0 version of these, which Xalan does not yet support.)
&gt;
&gt; If you want to match names without looking at the namespace, you can
&gt; use wildcard QNames such as *:foo, or match on a wildcard and then
&gt; qualify that with a predicate.

I believe that form [1] has only been supported since XPath 2.0. Pretty
sure XPath 1.0 [1] only allows foo:* wildcards (but not *:foo).

Thanks.

[1] http://www.w3.org/TR/xpath20/#prod-xpath-NameTest
[2] http://www.w3.org/TR/xpath#NT-NameTest

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>keshlam@us.ibm.com</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cOFA4F4A2E9.9A0B8847-ON8525767E.0059DDB2-8525767E.005A42CB@lotus.com%3e"/>
<id>urn:uuid:%3cOFA4F4A2E9-9A0B8847-ON8525767E-0059DDB2-8525767E-005A42CB@lotus-com%3e</id>
<updated>2009-11-30T16:28:36Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
&gt; As we have xs:any in xerces for any namespace usage , how do I 
&gt; achieve in xslt ? I could not find any construct in xsl as we have 
&gt; in schema language.

XSLT 1.0 and XPath 1.0 are not schema-aware. (That was added in the 2.0 
version of these, which Xalan does not yet support.)

If you want to match names without looking at the namespace, you can use 
wildcard QNames such as *:foo, or match on a wildcard and then qualify 
that with a predicate.

</pre>
</div>
</content>
</entry>
<entry>
<title>How to achieve in xslt equivalent to xs:any in xerces</title>
<author><name>ajay bhadauria &lt;abhadauria@yahoo.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c119356.40788.qm@web111512.mail.gq1.yahoo.com%3e"/>
<id>urn:uuid:%3c119356-40788-qm@web111512-mail-gq1-yahoo-com%3e</id>
<updated>2009-11-30T16:19:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi all,

As we have xs:any in xerces for any namespace usage , how do I achieve in xslt ? I could not
find any construct in xsl as we have in schema language.

Could you please tell me,  is there any way we can achieve the same thing like xs:any ??

Regards
Ajay  


      


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: fo:external-graphic and xml:base</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c20091124003316.GC3692@wladimir%3e"/>
<id>urn:uuid:%3c20091124003316-GC3692@wladimir%3e</id>
<updated>2009-11-24T00:33:16Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Nathan Nadeau schrieb am 23.11.2009 um 18:12:01 (-0500):
&gt; The source of the problem is that FOP is mistakenly calculating the
&gt; base-URI for the images. The purpose of xml:base is to rectify
&gt; situations like this, but it seems that FOP does not know what to do
&gt; with xml:base. For you, it's reporting xml:base as an invalid
&gt; attribute of the fo:block element. For me, it just ignores xml:base
&gt; and continues (of course still incorrectly resolving the image URIs).
&gt; 
&gt; First thing I would verify is that your XSLT and/or XSL-FO files are
&gt; aware of the "xml" namespace. I tried this first on my setup, but it
&gt; did not help. Maybe it will help you?

Can't help with FOP, but as for the "xml" namespace, it does not need to
be declared as it is by default.

http://www.w3.org/TR/xml-names/#ns-decl

  Namespace constraint: Reserved Prefixes and Namespace Names

  The prefix xml is by definition bound to the namespace name
  http://www.w3.org/XML/1998/namespace. It MAY, but need not,
  be declared, and MUST NOT be bound to any other namespace
  name. Other prefixes MUST NOT be bound to this namespace
  name, and it MUST NOT be declared as the default namespace.

Note that the notion of *files* being "aware" of the "xml" namespace is
misleading. A *parser* implementing namespaces is required to have a
binding for "xml" to the appropriate namespace.

Next, there needs to be support for xml:base. XSLT 1.0, which was
published in 1999 [1], does not mention xml:base, which was published
two years later [2]. However, there is support for base URIs.

Support for enhanced base URIs as per the 2001 xml:base add-on is up to
the implementation:

* Saxon 6.5      - yes
* LibXSLT 1.1.24 - yes
* Xalan-J 2.7.1  - no

Last, in XSLT/XPath 2.0 you can access the base URI directly using the
base-uri() function [3].

[1] http://www.w3.org/TR/xslt#base-uri
[2] http://www.w3.org/TR/xmlbase/
[3] http://www.w3.org/TR/xpath-functions/#func-base-uri

-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: fo:external-graphic and xml:base</title>
<author><name>Nathan Nadeau &lt;ndn@gleim.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c4B0B16C1.1040507@gleim.com%3e"/>
<id>urn:uuid:%3c4B0B16C1-1040507@gleim-com%3e</id>
<updated>2009-11-23T23:12:01Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
The source of the problem is that FOP is mistakenly calculating the 
base-URI for the images. The purpose of xml:base is to rectify 
situations like this, but it seems that FOP does not know what to do 
with xml:base. For you, it's reporting xml:base as an invalid attribute 
of the fo:block element. For me, it just ignores xml:base and continues 
(of course still incorrectly resolving the image URIs).

First thing I would verify is that your XSLT and/or XSL-FO files are 
aware of the "xml" namespace. I tried this first on my setup, but it did 
not help. Maybe it will help you?

If that doesn't work, there are certainly ways to work around the problem:

1) Download the images to a corresponding local directory in a 
pre-processing step. Or you could program a Xalan extension that 
basically does the same thing "inline" in the XSLT.

2) Explicitly compute the base URI for the particular HTML document 
you're processing and use that value to create an absolute URI in 
&lt;fo:external-graphic&gt;. Something like "concat($base-URI,@src)". You 
could either pass in $base-URI as a global XSLT parameter (if you know 
this beforehand), or you can calculate it dynamically for each document 
you process by finding the directory of the a/@href attribute (the 
portion of the URI leading up to the file, but not the file name 
itself). Then you'd send that value along to the matching templates with 
&lt;xsl:apply-templates&gt;&lt;xsl:with-param name="base-URI" select="blah"/&gt;, 
and you'd need to make sure your matching templates include that 
parameter with &lt;xsl:param name="base-URI"/&gt;. Then, when you're 
outputting the external graphic, you'd do something like 
&lt;fo:external-graphic src="url('{concat($base-URI,@src)}')"/&gt;.

3) Tell FOP to use a given base-URI via the configuration file. See 
http://xmlgraphics.apache.org/fop/0.94/configuration.html. It seems you 
can only do this if you already know the base-URI value beforehand, and 
you can only have one value per FOP run. I actually used this option 
with your example files and it worked for me. No change was needed to 
your files, and I didn't need to use xml:base, but of course you need to 
know the base-URI beforehand, or otherwise somehow loop through calls to 
FOP, updating the config file appropriately on each call.

Cheers,
Nathan Nadeau


Jack Bates wrote:
&gt; I originally posted this question to the FOP users list,
&gt; http://thread.gmane.org/gmane.text.xml.fop.user/29778
&gt;
&gt; I'm writing a stylesheet that includes this template,
&gt;
&gt;   &lt;xsl:template match="html:img"&gt;
&gt;     &lt;fo:external-graphic src="url('{@src}')"/&gt;
&gt;   &lt;/xsl:template&gt;
&gt;
&gt; - but when I process it I get errors like,
&gt;
&gt;  $ fop -xml index.html -xsl index.xsl index.pdf
&gt;  [...]
&gt;  16-Nov-2009 11:06:32 AM org.apache.fop.events.LoggingEventListener processEvent
&gt;  SEVERE: Image not found. URI: /docs/images/thumb/b/bb/UM-2.1.png/500px-UM-2.1.png. (No
context info available)
&gt;  [...]
&gt;
&gt; - and the generated PDF is missing some images : (
&gt;
&gt; I think the problem is that the stylesheet uses the document() function
&gt; to get HTML pages from the web,
&gt;
&gt;   &lt;xsl:template match="html:a" mode="foo"&gt;
&gt;     &lt;fo:block&gt;
&gt;       &lt;xsl:apply-templates select="document(@href)//html:body"/&gt;
&gt;     &lt;/fo:block&gt;
&gt;   &lt;/xsl:template&gt;
&gt;
&gt; - and these pages, e.g. http://ica-atom.org/docs/index.php?title=UM-2.1
&gt;
&gt; - have some relative images,
&gt; e.g. /docs/images/thumb/b/bb/UM-2.1.png/500px-UM-2.1.png
&gt;
&gt; The &lt;img&gt; elements are part of the HTML document, and so relative to
&gt; http://ica-atom.org/docs/index.php?title=UM-2.1, but I guess the
&gt; &lt;external-graphic&gt; elements aren't?
&gt;
&gt; I tried adding an xml:base="" attribute,
&gt;
&gt;   &lt;xsl:template match="html:a" mode="foo"&gt;
&gt;     &lt;fo:block xml:base="{@href}"&gt;
&gt;       &lt;xsl:apply-templates select="document(@href)//html:body"/&gt;
&gt;     &lt;/fo:block&gt;
&gt;   &lt;/xsl:template&gt;
&gt;
&gt; Here's a simplified, complete example,
&gt;
&gt; http://www.sfu.ca/~jdbates/tmp/fop/200911160/index.html
&gt;
&gt; http://www.sfu.ca/~jdbates/tmp/fop/200911160/index.xsl
&gt;
&gt; - but now when I process this example I get this error,
&gt;
&gt;  $ fop -xml index.html -xsl index.xsl index.pdf
&gt;  16-Nov-2009 11:29:57 AM org.apache.fop.cli.Main startFOP
&gt;  SEVERE: Exception
&gt;  javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Invalid
property encountered on "fo:block": xml:base (No context info available)
&gt;          at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:314)
&gt;          at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:146)
&gt;          at org.apache.fop.cli.Main.startFOP(Main.java:174)
&gt;          at org.apache.fop.cli.Main.main(Main.java:205)
&gt;  [...]
&gt;
&gt; How can I automatically convert these HTML pages to a PDF with XSL-FO?
&gt;   


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Loosing significant space in LSSerializer</title>
<author><name>Michael Glavassevich &lt;mrglavas@ca.ibm.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cOFF462A0C4.0B9E2D72-ON85257676.007A4B44-85257676.007BD264@ca.ibm.com%3e"/>
<id>urn:uuid:%3cOFF462A0C4-0B9E2D72-ON85257676-007A4B44-85257676-007BD264@ca-ibm-com%3e</id>
<updated>2009-11-22T22:32:27Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Content-type: text/plain; charset=US-ASCII

Right, that's exactly how it works:

    public LSSerializer createLSSerializer() {
        try {
            Class serializerClass = ObjectFactory.findProviderClass(
                "org.apache.xml.serializer.dom3.LSSerializerImpl",
                ObjectFactory.findClassLoader(), true);
            return (LSSerializer) serializerClass.newInstance();
        }
        catch (Exception e) {}
        // Fall back to Xerces' deprecated serializer if
        // the Xalan based serializer is unavailable.
        return new DOMSerializerImpl();
    }

Was hoping to put a warning in there if it takes the fallback path but
there's no DOMErrorHandler to report it to at this point.

FYI: If you don't have Xerces on the classpath but instead try to access
the JDK version [1] you may not get very far.

Thanks.

[1] http://markmail.org/message/e6rlhwymr43p4u4v

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Dick Deneer &lt;dick.deneer@donkeydevelopment.com&gt; wrote on 11/22/2009
04:06:06 PM:

&gt; Hi Benson,
&gt;
&gt; As Michael notes, Xerces is now shipped with the serializer.jar
&gt; (which contains the xalan serializer). If you have this on your
&gt; classpath it will be used.
&gt; If you leave it out, then xerces will fall back to it's own (deprecated)
one.
&gt;
&gt; regards
&gt; Dick Deneer
&gt; Op 22-nov-2009, om 21:54 heeft Benson Margulies het volgende geschreven:
&gt;
&gt; Hi Michael,
&gt;
&gt; So, if I put Xerces and not Xalan into classpath, and ask a document
&gt; for it's implementation, and ask that for the DOMImplementationLS,
&gt; what do I get? Whatever Sun tossed into the pot? And if I then add
&gt; Xalan, do I get the right one?
&gt;
&gt; --benson
&gt;

&gt; On Sat, Nov 21, 2009 at 10:24 PM, Michael Glavassevich
&lt;mrglavas@ca.ibm.com
&gt; &gt; wrote:
&gt; Hi Benson,
&gt;
&gt; We're talking about two different implementations of the DOM Level 3
&gt; LSSerializer, the more recently developed one in Xalan
&gt; (serializer.jar which Xerces now ships and shares with Xalan) and
&gt; the much older deprecated one in Xerces. If you're curious about the
&gt; history on that, there's an FAQ [1] on the website.
&gt;
&gt; Some users have decided to keep using Xerces' deprecated serializer
&gt; due to some quirks and issues with the currently available one from
&gt; Xalan. Folks really should be opening JIRA issues [2] against Xalan,
&gt; so those problems get addressed there. There's no intention to do
&gt; any further development or fixes to the one in Xerces.
&gt;
&gt; Thanks.
&gt;
&gt; [1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
&gt; [2] https://issues.apache.org/jira/browse/XALANJ
&gt;
&gt;
&gt; Michael Glavassevich
&gt; XML Parser Development
&gt; IBM Toronto Lab
&gt; E-mail: mrglavas@ca.ibm.com
&gt; E-mail: mrglavas@apache.org

&gt; Benson Margulies &lt;bimargulies@gmail.com&gt; wrote on 11/21/2009 02:17:49 PM:
&gt;
&gt;
&gt; &gt; Could I please ask for a bit of clarification? The only LSSerializer
&gt; &gt; I'm aware of is the DOM level 3 stuff, which, I thought, was the
&gt; &gt; opposite of obsolete. As someone pointed out here, unlike TraX, it
&gt; &gt; will serialize doctypes and do other handy things. In general, I'm
&gt; &gt; beginning to prefer the DOMImplementationLS to JAXP and TraX.
&gt;
&gt; &gt; On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich
&lt;mrglavas@ca.ibm.com
&gt; &gt; &gt; wrote:
&gt; &gt; You should also be able to control whether spaces are preserved by
&gt; &gt; registering an LSSerializerFilter.
&gt; &gt;
&gt; &gt; When I added one to your test program:
&gt; &gt;
&gt; &gt;         if (useXerces)
&gt; &gt;         {
&gt; &gt;             domWriter = new DOMSerializerImpl();
&gt; &gt;             domWriter.setFilter(new LSSerializerFilter() {
&gt; &gt;                 public int getWhatToShow() {
&gt; &gt;                     return LSSerializerFilter.SHOW_ALL;
&gt; &gt;                 }
&gt; &gt;                 public short acceptNode(Node n) {
&gt; &gt;                     return LSSerializerFilter.FILTER_ACCEPT;
&gt; &gt;                 }});
&gt; &gt;         }
&gt; &gt;
&gt; &gt; the output I get is:
&gt; &gt;
&gt; &gt;
&gt; &gt; Program started
&gt; &gt; Xerces serializer will be used
&gt; &gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;
&gt; &gt; &lt;root&gt;
&gt; &gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &lt;child2&gt; &lt;/child2&gt;
&gt; &gt;
&gt; &gt; &lt;/root&gt;
&gt; &gt;
&gt; &gt; Xalan serializer will be used
&gt; &gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;&lt;root&gt;
&gt; &gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &lt;child2&gt; &lt;/child2&gt;
&gt; &gt; &lt;/root&gt;
&gt;
&gt; &gt; which I believe is what you were expecting.
&gt; &gt;
&gt; &gt; Thanks.
&gt; &gt;
&gt; &gt; Michael Glavassevich
&gt; &gt; XML Parser Development
&gt; &gt; IBM Toronto Lab
&gt; &gt; E-mail: mrglavas@ca.ibm.com
&gt; &gt; E-mail: mrglavas@apache.org
&gt; &gt;
&gt; &gt; Dick Deneer &lt;dick.deneer@donkeydevelopment.com&gt; wrote on 11/21/2009
&gt; &gt; 01:19:27 PM:
&gt; &gt;
&gt; &gt;
&gt; &gt; &gt; Hi Jake,
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt; I just tried your suggestion and the spaces are indeed preserved.
&gt; &gt; &gt; But still, I woud prefer another solution. I do not have any clue
&gt; &gt; &gt; about the xml (I use xerces in a xml editor) and I do not want to
&gt; &gt; &gt; change the xml.
&gt; &gt; &gt; And also I would like to stay with the LSSerializer (it also
&gt; &gt; &gt; serilalizes doctype nodes).
&gt; &gt; &gt; If there is another way please let me know.
&gt; &gt; &gt;
&gt; &gt; &gt; Thanks
&gt; &gt; &gt; Dick Deneer
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt; Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
&gt; &gt; &gt;
&gt; &gt; &gt; &gt; Have you tried xml:space="preserve"?
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt; Jake
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt; On 11/20/2009 4:36 PM, Dick Deneer wrote:
&gt; &gt; &gt; &gt;&gt; I am still using the deprecated LSSerializer because the xalan
&gt; &gt; &gt; &gt;&gt; serializer has issues with the pretty print.
&gt; &gt; &gt; &gt;&gt; But when I have simple elements with only space, the serializer
&gt; &gt; &gt; &gt;&gt; produces
&gt; &gt; &gt; &gt;&gt; empty elements. Is there a tweak to keep the spaces in this
elements?
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Sample xml:
&gt; &gt; &gt; &gt;&gt; &lt;root&gt;&lt;child1&gt;text&lt;/child1&gt;&lt;child2&gt; &lt;/child2&gt;&lt;/root&gt;
&gt; &gt; &gt; &gt;&gt; I attached a simple test program, that you can just run to see the

&gt; &gt; &gt; &gt;&gt; results:
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Program started
&gt; &gt; &gt; &gt;&gt; Xerces serializer will be used
&gt; &gt; &gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;
&gt; &gt; &gt; &gt;&gt; &lt;root&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child2/&gt;
&gt; &gt; &gt; &gt;&gt; &lt;/root&gt;
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Xalan serializer will be used
&gt; &gt; &gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;&lt;root&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child2&gt; &lt;/child2&gt;
&gt; &gt; &gt; &gt;&gt; &lt;/root&gt;
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Regards
&gt; &gt; &gt; &gt;&gt; Dick Deneer
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt;
---------------------------------------------------------------------
&gt; &gt; &gt; &gt;&gt; ---
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt;
---------------------------------------------------------------------
&gt; &gt; &gt; &gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
&gt; &gt; &gt; &gt; For additional commands, e-mail: j-users-help@xerces.apache.org
&gt; &gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt; ---------------------------------------------------------------------
&gt; &gt; &gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
&gt; &gt; &gt; For additional commands, e-mail: j-users-help@xerces.apache.org

</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Loosing significant space in LSSerializer</title>
<author><name>Benson Margulies &lt;bimargulies@gmail.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c61b5d9410911221254u1c801f5fhbec2d335b8637f2e@mail.gmail.com%3e"/>
<id>urn:uuid:%3c61b5d9410911221254u1c801f5fhbec2d335b8637f2e@mail-gmail-com%3e</id>
<updated>2009-11-22T20:54:37Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi Michael,

So, if I put Xerces and not Xalan into classpath, and ask a document for
it's implementation, and ask that for the DOMImplementationLS, what do I
get? Whatever Sun tossed into the pot? And if I then add Xalan, do I get the
right one?

--benson


On Sat, Nov 21, 2009 at 10:24 PM, Michael Glavassevich
&lt;mrglavas@ca.ibm.com&gt;wrote:

&gt; Hi Benson,
&gt;
&gt; We're talking about two different implementations of the DOM Level 3
&gt; LSSerializer, the more recently developed one in Xalan (serializer.jar which
&gt; Xerces now ships and shares with Xalan) and the much older deprecated one in
&gt; Xerces. If you're curious about the history on that, there's an FAQ [1] on
&gt; the website.
&gt;
&gt; Some users have decided to keep using Xerces' deprecated serializer due to
&gt; some quirks and issues with the currently available one from Xalan. Folks
&gt; really should be opening JIRA issues [2] against Xalan, so those problems
&gt; get addressed there. There's no intention to do any further development or
&gt; fixes to the one in Xerces.
&gt;
&gt; Thanks.
&gt;
&gt; [1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
&gt; [2] https://issues.apache.org/jira/browse/XALANJ
&gt;
&gt;
&gt; Michael Glavassevich
&gt; XML Parser Development
&gt; IBM Toronto Lab
&gt; E-mail: mrglavas@ca.ibm.com
&gt; E-mail: mrglavas@apache.org
&gt;
&gt; Benson Margulies &lt;bimargulies@gmail.com&gt; wrote on 11/21/2009 02:17:49 PM:
&gt;
&gt;
&gt; &gt; Could I please ask for a bit of clarification? The only LSSerializer
&gt; &gt; I'm aware of is the DOM level 3 stuff, which, I thought, was the
&gt; &gt; opposite of obsolete. As someone pointed out here, unlike TraX, it
&gt; &gt; will serialize doctypes and do other handy things. In general, I'm
&gt; &gt; beginning to prefer the DOMImplementationLS to JAXP and TraX.
&gt;
&gt; &gt; On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich &lt;
&gt; mrglavas@ca.ibm.com
&gt; &gt; &gt; wrote:
&gt; &gt; You should also be able to control whether spaces are preserved by
&gt; &gt; registering an LSSerializerFilter.
&gt; &gt;
&gt; &gt; When I added one to your test program:
&gt; &gt;
&gt; &gt;         if (useXerces)
&gt; &gt;         {
&gt; &gt;             domWriter = new DOMSerializerImpl();
&gt; &gt;             domWriter.setFilter(new LSSerializerFilter() {
&gt; &gt;                 public int getWhatToShow() {
&gt; &gt;                     return LSSerializerFilter.SHOW_ALL;
&gt; &gt;                 }
&gt; &gt;                 public short acceptNode(Node n) {
&gt; &gt;                     return LSSerializerFilter.FILTER_ACCEPT;
&gt; &gt;                 }});
&gt; &gt;         }
&gt; &gt;
&gt; &gt; the output I get is:
&gt; &gt;
&gt; &gt;
&gt; &gt; Program started
&gt; &gt; Xerces serializer will be used
&gt; &gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;
&gt; &gt; &lt;root&gt;
&gt; &gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &lt;child2&gt; &lt;/child2&gt;
&gt; &gt;
&gt; &gt; &lt;/root&gt;
&gt; &gt;
&gt; &gt; Xalan serializer will be used
&gt; &gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;&lt;root&gt;
&gt; &gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &lt;child2&gt; &lt;/child2&gt;
&gt; &gt; &lt;/root&gt;
&gt;
&gt; &gt; which I believe is what you were expecting.
&gt; &gt;
&gt; &gt; Thanks.
&gt; &gt;
&gt; &gt; Michael Glavassevich
&gt; &gt; XML Parser Development
&gt; &gt; IBM Toronto Lab
&gt; &gt; E-mail: mrglavas@ca.ibm.com
&gt; &gt; E-mail: mrglavas@apache.org
&gt; &gt;
&gt; &gt; Dick Deneer &lt;dick.deneer@donkeydevelopment.com&gt; wrote on 11/21/2009
&gt; &gt; 01:19:27 PM:
&gt; &gt;
&gt; &gt;
&gt; &gt; &gt; Hi Jake,
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt; I just tried your suggestion and the spaces are indeed preserved.
&gt; &gt; &gt; But still, I woud prefer another solution. I do not have any clue
&gt; &gt; &gt; about the xml (I use xerces in a xml editor) and I do not want to
&gt; &gt; &gt; change the xml.
&gt; &gt; &gt; And also I would like to stay with the LSSerializer (it also
&gt; &gt; &gt; serilalizes doctype nodes).
&gt; &gt; &gt; If there is another way please let me know.
&gt; &gt; &gt;
&gt; &gt; &gt; Thanks
&gt; &gt; &gt; Dick Deneer
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt; Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
&gt; &gt; &gt;
&gt; &gt; &gt; &gt; Have you tried xml:space="preserve"?
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt; Jake
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt; On 11/20/2009 4:36 PM, Dick Deneer wrote:
&gt; &gt; &gt; &gt;&gt; I am still using the deprecated LSSerializer because the xalan
&gt; &gt; &gt; &gt;&gt; serializer has issues with the pretty print.
&gt; &gt; &gt; &gt;&gt; But when I have simple elements with only space, the serializer
&gt; &gt; &gt; &gt;&gt; produces
&gt; &gt; &gt; &gt;&gt; empty elements. Is there a tweak to keep the spaces in this
&gt; elements?
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Sample xml:
&gt; &gt; &gt; &gt;&gt; &lt;root&gt;&lt;child1&gt;text&lt;/child1&gt;&lt;child2&gt; &lt;/child2&gt;&lt;/root&gt;
&gt; &gt; &gt; &gt;&gt; I attached a simple test program, that you can just run to see the
&gt; &gt; &gt; &gt;&gt; results:
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Program started
&gt; &gt; &gt; &gt;&gt; Xerces serializer will be used
&gt; &gt; &gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;
&gt; &gt; &gt; &gt;&gt; &lt;root&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child2/&gt;
&gt; &gt; &gt; &gt;&gt; &lt;/root&gt;
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Xalan serializer will be used
&gt; &gt; &gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;&lt;root&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt; &gt; &gt;&gt; &lt;child2&gt; &lt;/child2&gt;
&gt; &gt; &gt; &gt;&gt; &lt;/root&gt;
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt; Regards
&gt; &gt; &gt; &gt;&gt; Dick Deneer
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;&gt;
&gt; ---------------------------------------------------------------------
&gt; &gt; &gt; &gt;&gt; ---
&gt; &gt; &gt; &gt;&gt;
&gt; &gt; &gt; &gt;
&gt; &gt; &gt; &gt; ---------------------------------------------------------------------
&gt; &gt; &gt; &gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
&gt; &gt; &gt; &gt; For additional commands, e-mail: j-users-help@xerces.apache.org
&gt; &gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt;
&gt; &gt; &gt; ---------------------------------------------------------------------
&gt; &gt; &gt; To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
&gt; &gt; &gt; For additional commands, e-mail: j-users-help@xerces.apache.org
&gt;


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Loosing significant space in LSSerializer</title>
<author><name>Michael Glavassevich &lt;mrglavas@ca.ibm.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cOF6D78CBA1.E93F2A55-ON85257676.005575B6-85257676.0055A442@ca.ibm.com%3e"/>
<id>urn:uuid:%3cOF6D78CBA1-E93F2A55-ON85257676-005575B6-85257676-0055A442@ca-ibm-com%3e</id>
<updated>2009-11-22T15:35:25Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Content-type: text/plain; charset=US-ASCII

(Copying xalan-j-users to this thread.)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Michael Glavassevich &lt;mrglavas@ca.ibm.com&gt; wrote on 11/22/2009 10:30:49 AM:

&gt; Dick Deneer &lt;dick.deneer@donkeydevelopment.com&gt; wrote on 11/22/2009
&gt; 06:33:28 AM:
&gt;
&gt; &gt; Michael,
&gt; &gt;
&gt; &gt; Thank you for this suggestion.
&gt; &gt; I can use this. Before I call the serializer I will strip off all
&gt; &gt; whitespace in "whitespace-only" complex nodes because otherwise I do
&gt; &gt; not get a pretty-print:
&gt; &gt; For example:
&gt; &gt; String xml = "&lt;root&gt;" +
&gt; &gt; "                                  &lt;child1&gt;text&lt;/child1&gt;&lt;child2&gt;
&gt; &gt; &lt;/child2&gt;&lt;/root&gt;";
&gt; &gt; results in :
&gt; &gt; &lt;?xml version="1.0" encoding="UTF-16"?&gt;
&gt; &gt; &lt;root&gt;                                  &lt;child1&gt;text&lt;/child1&gt;
&gt; &gt;     &lt;child2&gt;   &lt;/child2&gt;
&gt; &gt; &lt;/root&gt;
&gt; &gt;
&gt; &gt; But stripping of this whitespace before will not be too difficult.
&gt; &gt;
&gt; &gt; I feel it is a pitty that the LSSerializer will not be maintained
&gt; &gt; anymore, because we do not have alternatives that supply the same
&gt; &gt; functionality.
&gt;
&gt; It is in Xalan. Their serializer started as a copy of the Xerces one
&gt; (even has similar package names: org.apache.xml.serialize vs.
&gt; org.apache.xml.serializer). We didn't want to duplicate the effort
&gt; anymore and decided to combine forces and the Xalan one was chosen
&gt; as the common codebase because it was better maintained and was
&gt; making significant improvements to performance. Its LSSerializer
&gt; implementation was written by a Xerces committer and I have made
&gt; improvements and fixes to it too where I've found issues, so it's
&gt; being jointly maintained, though in a different project. This is the
&gt; alternative. It *is* an LSSerializer and there is no reason that it
&gt; can't be updated / fixed to have similar behaviour, but that's only
&gt; likely to happen if users report the problems they're having
&gt; (patches are welcome), preferably in JIRA.
&gt;
&gt; &gt; I am afraid that maybe in the future there may be new xml (or DOM)
&gt; &gt; feautures that have effects on the serialization. Then we are
&gt; &gt; totally dependent on other libraries to implement that functionality.
&gt; &gt;
&gt; &gt; But I understand you have to make choices where to spent the effort.
&gt; &gt;
&gt; &gt; Thanks
&gt; &gt; Dick Deneer
&gt;
&gt; Thanks.
&gt;
&gt; Michael Glavassevich
&gt; XML Parser Development
&gt; IBM Toronto Lab
&gt; E-mail: mrglavas@ca.ibm.com
&gt; E-mail: mrglavas@apache.org

</pre>
</div>
</content>
</entry>
<entry>
<title>fo:external-graphic and xml:base</title>
<author><name>Jack Bates &lt;ms419@freezone.co.uk&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c1258861501.19116.32.camel@tad%3e"/>
<id>urn:uuid:%3c1258861501-19116-32-camel@tad%3e</id>
<updated>2009-11-22T03:45:01Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
I originally posted this question to the FOP users list,
http://thread.gmane.org/gmane.text.xml.fop.user/29778

I'm writing a stylesheet that includes this template,

  &lt;xsl:template match="html:img"&gt;
    &lt;fo:external-graphic src="url('{@src}')"/&gt;
  &lt;/xsl:template&gt;

- but when I process it I get errors like,

 $ fop -xml index.html -xsl index.xsl index.pdf
 [...]
 16-Nov-2009 11:06:32 AM org.apache.fop.events.LoggingEventListener processEvent
 SEVERE: Image not found. URI: /docs/images/thumb/b/bb/UM-2.1.png/500px-UM-2.1.png. (No context
info available)
 [...]

- and the generated PDF is missing some images : (

I think the problem is that the stylesheet uses the document() function
to get HTML pages from the web,

  &lt;xsl:template match="html:a" mode="foo"&gt;
    &lt;fo:block&gt;
      &lt;xsl:apply-templates select="document(@href)//html:body"/&gt;
    &lt;/fo:block&gt;
  &lt;/xsl:template&gt;

- and these pages, e.g. http://ica-atom.org/docs/index.php?title=UM-2.1

- have some relative images,
e.g. /docs/images/thumb/b/bb/UM-2.1.png/500px-UM-2.1.png

The &lt;img&gt; elements are part of the HTML document, and so relative to
http://ica-atom.org/docs/index.php?title=UM-2.1, but I guess the
&lt;external-graphic&gt; elements aren't?

I tried adding an xml:base="" attribute,

  &lt;xsl:template match="html:a" mode="foo"&gt;
    &lt;fo:block xml:base="{@href}"&gt;
      &lt;xsl:apply-templates select="document(@href)//html:body"/&gt;
    &lt;/fo:block&gt;
  &lt;/xsl:template&gt;

Here's a simplified, complete example,

http://www.sfu.ca/~jdbates/tmp/fop/200911160/index.html

http://www.sfu.ca/~jdbates/tmp/fop/200911160/index.xsl

- but now when I process this example I get this error,

 $ fop -xml index.html -xsl index.xsl index.pdf
 16-Nov-2009 11:29:57 AM org.apache.fop.cli.Main startFOP
 SEVERE: Exception
 javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: Invalid
property encountered on "fo:block": xml:base (No context info available)
         at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:314)
         at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:146)
         at org.apache.fop.cli.Main.startFOP(Main.java:174)
         at org.apache.fop.cli.Main.main(Main.java:205)
 [...]

How can I automatically convert these HTML pages to a PDF with XSL-FO?


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Advanced Extension Element Question</title>
<author><name>keshlam@us.ibm.com</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cOFE46AEB6E.C5FB83D0-ON8525766D.00750394-8525766D.0075D8F5@lotus.com%3e"/>
<id>urn:uuid:%3cOFE46AEB6E-C5FB83D0-ON8525766D-00750394-8525766D-0075D8F5@lotus-com%3e</id>
<updated>2009-11-13T21:29:55Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
&gt; Can anyone tell me if there's any way to add an object (not node or 
&gt; tree fragment) variable to the variable stack from an extension element?

&gt;From an extension _element_... I don't think so.


&gt;From an extension _function_, yes. If the returned value is not an 
instanceof one of the types called out in the mapping table (
http://xml.apache.org/xalan-j/extensions.html#ext-functions), it will be 
returned as an object reference. Generally you can't do much with those 
except store them in variables and/or pass them as parameters to other 
extensions.

If your returned value *is* an instanceof one of those types... The best 
suggestion I can give you is to set up a wrapper object which does not 
implement those types, return the wrapper, and have whoever is using the 
value unwrap it again before accessing it.

</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Advanced Extension Element Question</title>
<author><name>Adam Jenkins &lt;adamjenkinstmpredirect@yahoo.com.au&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c232345.70930.qm@web35908.mail.mud.yahoo.com%3e"/>
<id>urn:uuid:%3c232345-70930-qm@web35908-mail-mud-yahoo-com%3e</id>
<updated>2009-11-13T21:10:46Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Can anyone tell me if there's any way to add an object (not node or tree fragment) variable
to the variable stack from an extension element?

I originally tried to use context.outputToResultTree(context.getStylesheet(), myCreatedObject)
an put my extension element inside an &lt;xsl:variable...&gt;, however that turns my java
object into a text node on a Document first (the text node has the value of the toString()
from my object) rather than passing myCreatedObject to the ElemVariable element as a java
object.

I'm now looking into doing a similar thing as in ElemVariable.java and adding the object to
the stack directly from within my extension element method, from what I can see, this should
work:

StylesheetRoot root = xslProcessorContext.getStylesheet().getStylesheetRoot();
StylesheetRoot.ComposeState cstate = sroot.getComposeState();
QName name = new QName(name);
XObject obj = new XObject(myCreatedObject);
int index = cstate.addVariableName(name) - cstate.getGlobalsSize();
xslProcessorContext.getTransformer().getXPathContext().getVarStack().setLocalVariable(index,
obj);

Now this is similar to what ElemVariable.java does, however StylesheetRoot.ComposeState is
package scoped!, so I can't use the above code either :(

If anyone knows of a way to put a java object variable onto the variable stack (as an XObject,
not a XRTreeFrag) under a given name from within an extension element method I'd really appreciate
any pointers you could give.

My goals is placing an object into the local variable stack under a given name so that I can
reference it, for example in an &lt;xsl:value-of select="java:someMethod($myPreviouslyAddedObject)"/&gt;

--- On Fri, 13/11/09, Adam Jenkins &lt;adamjenkinstmpredirect@yahoo.com.au&gt; wrote:

&gt; From: Adam Jenkins &lt;adamjenkinstmpredirect@yahoo.com.au&gt;
&gt; Subject: Advanced Extension Element Question
&gt; To: xalan-j-users@xml.apache.org, xalan-dev@xml.apache.org
&gt; Received: Friday, 13 November, 2009, 5:53 PM
&gt; Hi All,
&gt; 
&gt; I'm just wondering if there is a way to place a java object
&gt; (not a tree fragment) into the context output results from
&gt; an extension element, and have it stay as an object (and not
&gt; have it turned into a Document node).
&gt; 
&gt; Here is the exact use case.  I have a custom extension
&gt; that creates an object that is used later on throughout my
&gt; xslt.  The use case I want is:
&gt; 
&gt; &lt;xsl:variable name="somevarname"&gt;
&gt;    &lt;custom:myobject&gt;
&gt;       &lt;custom:property name="blah"
&gt; value="blah"/&gt;
&gt;    &lt;/custom:myobject&gt;
&gt; &lt;/xsl:variable&gt;
&gt; 
&gt; The function myObject(XSLProcessorContext,
&gt; ElemExtensionCall) on the object mapped to the prefix
&gt; 'custom' creates a java object, and places it to the output
&gt; tree thus:
&gt; 
&gt; context.outputToResultTree(context.getStylesheet(),
&gt; myCreatedObject);
&gt; 
&gt; Now, when I try to reference that later, it's been turned
&gt; into a text node on a Document object whos value is the
&gt; value of the toString() method for 'myCreatedObject'. 
&gt; So I think I'm using the wrong method here...and that
&gt; perhaps there's a better method other than
&gt; outputToResultTree??
&gt; 
&gt; So I'm guessing xalan &lt;xsl:variable...&gt; tag is
&gt; creating a document fragment from my object as best it can.
&gt; 
&gt; So my question is...is there anyway, to pass
&gt; myCreatedObject up to the previous &lt;xsl:variable...&gt;
&gt; declaration without it being toStringed (another method
&gt; somewhere).
&gt; 
&gt; My fallback is to declare a varName attribute on all my
&gt; custom extension and put the object on the local variable
&gt; stack myself, but that's a pain and looks ugly, I'd prefer
&gt; to do it using xsl:variable.
&gt; 
&gt; This is for an open source (large) xalan extension library
&gt; to be releases asap.
&gt; 
&gt; Cheers
&gt; Adam
&gt; 
&gt; 
&gt;      
&gt; __________________________________________________________________________________
&gt; Win 1 of 4 Sony home entertainment packs thanks to
&gt; Yahoo!7.
&gt; Enter now: http://au.docs.yahoo.com/homepageset/
&gt; 


      __________________________________________________________________________________
Win 1 of 4 Sony home entertainment packs thanks to Yahoo!7.
Enter now: http://au.docs.yahoo.com/homepageset/


</pre>
</div>
</content>
</entry>
<entry>
<title>&lt;xsl:message&gt; with terminate set to yes</title>
<author><name>Nathan Nadeau &lt;ndn@gleim.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c4AFDB061.2010806@gleim.com%3e"/>
<id>urn:uuid:%3c4AFDB061-2010806@gleim-com%3e</id>
<updated>2009-11-13T19:15:45Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi all,

I am using Xalan-J 2.7.1 from the command line via the 
org.apache.xalan.xslt.Process class. I have noticed that &lt;xsl:message 
terminate="yes"&gt; is no longer terminating the processing of the  
stylesheet. Instead the processor continues running and statements that 
come after the terminating &lt;xsl:message&gt; get  processed. The termination 
is handled the way you'd expect in 2.7.0 and earlier versions.

Test stylesheet:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="text"/&gt;
  &lt;xsl:template match="/"&gt;
    &lt;xsl:message terminate="yes"&gt;Terminating here...&lt;/xsl:message&gt;
    &lt;xsl:value-of select="'This should not be processed!'"/&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;

When I run this via org.apache.xalan.xslt.Process, I get the termination 
message ("Terminating here...") along with the line and column number 
information, but then it continues running and I see the second line of 
output ("This should not be processed!").

I understand that Process uses the DefaultErrorHandler class, and that 
according to the release notes for Xalan 2.7.0 (see 
http://xml.apache.org/xalan-j/readme.html, the "New default error 
handling behavior" section), the default ErrorListener was changed so 
that it no longer throws exceptions on errors or fatal errors. However 
in 2.7.0 the org.apache.xalan.xslt.Process still worked as expected, 
without any modifications.

This bug fix introduced the change in behavior of Process between 2.7.0 
and 2.7.1: 
http://issues.apache.org/jira/secure/ViewIssue.jspa?key=XALANJ-2317. 
Process went from instantiating DefaultErrorHandler with 
m_throwExceptionOnError=true to instantiating it with 
m_throwExceptionOnError=false. There were good reasons (I suppose) for 
making that change, but it seems to break the default handling of 
&lt;xsl:message terminate="yes"&gt;.

I was somewhat surprised to see that org.apache.xalan.xslt.Process was 
showing incorrect default behavior for &lt;xsl:message terminate="yes"&gt; 
right out of the box. Is this a bug or is this known/expected and I just 
need to alter Process myself or use my own error handler? I can simply 
"fix" this for my own uses by changing Processs to use "new 
DefaultErrorHandler(true)" but I'm worried about undoing the fixes for 
the problems listed in bug #2317.

I wanted to post to the mailing list before I tried submitting a bug 
report and working on a possible patch, to see if this was an actual 
problem or not.

Thanks for your help,

-- 
Nathan Nadeau
ndn@gleim.com
Software Development
Gleim Publications, Inc.
http://www.gleim.com



</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>&quot;Trenton D. Adams&quot; &lt;trenta@athabascau.ca&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c736221277.4523161258132361933.JavaMail.root@amundsen.cs.athabascau.ca%3e"/>
<id>urn:uuid:%3c736221277-4523161258132361933-JavaMail-root@amundsen-cs-athabascau-ca%3e</id>
<updated>2009-11-13T17:12:41Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
----- "Michael Ludwig" &lt;milu71@gmx.de&gt; wrote:

&gt; From: "Michael Ludwig" &lt;milu71@gmx.de&gt;
&gt; To: xalan-j-users@xml.apache.org
&gt; Sent: Thursday, November 12, 2009 7:08:24 PM GMT -07:00 US/Canada Mountain
&gt; Subject: Re: Stream Closed on xsl transformation
&gt;
&gt; Trenton D. Adams schrieb am 12.11.2009 um 16:19:35 (-0700):
&gt; &gt; I didn't send an attachment, I sent a link.  Do links get removed
&gt; too?
&gt; 
&gt; I must have been very tired when looking for the attachment.
&gt; 
&gt; &gt; As for it being 10k, the important part is that it does not work
&gt; with
&gt; &gt; a processing instruction of "&lt;?xml-stylesheet...?&gt;", but does work
&gt; &gt; without one (i.e. specifying one in the java code).  It's not the
&gt; &gt; XML/XSLT that is important to look at, but the Java code, which is
&gt; &gt; very small, and easy to follow, especially considering it's a
&gt; simple
&gt; &gt; JUnit test.
&gt; 
&gt; Maybe, but it is way more complex than it should have to be.
&gt; 
&gt; Anyway, I get two failures because of:
&gt; 
&gt;   junit.framework.AssertionFailedError
&gt;     caused by
&gt;   javax.xml.transform.TransformerException
&gt;     caused by
&gt;   java.net.UnknownHostException
&gt; 
&gt; And it is little wonder as your stylesheet PI misses a valid URI:
&gt; 
&gt;   &lt;?xml-stylesheet type="text/xsl"
&gt;     href="file://${basedir}/target/test-classes/transcript.xsl"?&gt;
&gt; 
&gt; Corrected this to:
&gt; 
&gt;   http://localhost/g/xml-util/target/test-classes/transcript.xsl

Yeah, that's because it's setup to use maven filtering.  You have to actually run it through
maven to work.  It replaces "basedir" with an appropriate path.

&gt; 
&gt; Now:
&gt; 
&gt;   junit.framework.AssertionFailedError
&gt;     caused by
&gt;   java.io.IOException: Stream closed
&gt; 
&gt; Okay, the error is in reading the PI from the StreamSource by calling
&gt; getAssociatedStylesheet(), and then trying to read again from the
&gt; same
&gt; StreamSource by calling transform(). Streams are to be used once
&gt; only.

Oh yes, in my rush to get a project done here, I hadn't though of the fact that you can't
use the source twice; which is duh, it uses a stream, hehe.  Silly me.

&gt; 
&gt; Fixing this in your program is cumbersome, because you have one big
&gt; method with parameters of type Object which you then cast to whatever
&gt; you need based on what instanceof tells you.
&gt; 
&gt;   public static String xslTransformation(
&gt;     final Object xml,
&gt;     final Object xsl,
&gt;     final Map parameters )
&gt; 
&gt; What's wrong with using polymorphism instead? It's vastly superior.

Well, v0.1.X is just a hack to get things done until I have time to fix it all up properly.
 That is initial development, it isn't always pretty.

&gt; 
&gt; Also, please consider providing simple test cases. You'd have
&gt; discovered
&gt; this error yourself if you had taken the time to build a simple test
&gt; case without so many complicating ingredients. It bears repeating
&gt; here
&gt; that simplifying is a basic problem solving technique.

I don't think it had much to do with the complexity of the code, as it isn't very complex.
 It had a lot more to do with rushing through.

Thanks for the suggestions though.

__ 
    This communication is intended for the use of the recipient to whom it
    is addressed, and may contain confidential, personal, and or privileged
    information. Please contact us immediately if you are not the intended
    recipient of this communication, and do not copy, distribute, or take
    action relying on it. Any communications received in error, or
    subsequent reply, should be deleted or destroyed.
---


</pre>
</div>
</content>
</entry>
<entry>
<title>Advanced Extension Element Question</title>
<author><name>Adam Jenkins &lt;adamjenkinstmpredirect@yahoo.com.au&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c588214.97161.qm@web35904.mail.mud.yahoo.com%3e"/>
<id>urn:uuid:%3c588214-97161-qm@web35904-mail-mud-yahoo-com%3e</id>
<updated>2009-11-13T06:53:57Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi All,

I'm just wondering if there is a way to place a java object (not a tree fragment) into the
context output results from an extension element, and have it stay as an object (and not have
it turned into a Document node).

Here is the exact use case.  I have a custom extension that creates an object that is used
later on throughout my xslt.  The use case I want is:

&lt;xsl:variable name="somevarname"&gt;
   &lt;custom:myobject&gt;
      &lt;custom:property name="blah" value="blah"/&gt;
   &lt;/custom:myobject&gt;
&lt;/xsl:variable&gt;

The function myObject(XSLProcessorContext, ElemExtensionCall) on the object mapped to the
prefix 'custom' creates a java object, and places it to the output tree thus:

context.outputToResultTree(context.getStylesheet(), myCreatedObject);

Now, when I try to reference that later, it's been turned into a text node on a Document object
whos value is the value of the toString() method for 'myCreatedObject'.  So I think I'm using
the wrong method here...and that perhaps there's a better method other than outputToResultTree??

So I'm guessing xalan &lt;xsl:variable...&gt; tag is creating a document fragment from my
object as best it can.

So my question is...is there anyway, to pass myCreatedObject up to the previous &lt;xsl:variable...&gt;
declaration without it being toStringed (another method somewhere).

My fallback is to declare a varName attribute on all my custom extension and put the object
on the local variable stack myself, but that's a pain and looks ugly, I'd prefer to do it
using xsl:variable.

This is for an open source (large) xalan extension library to be releases asap.

Cheers
Adam


      __________________________________________________________________________________
Win 1 of 4 Sony home entertainment packs thanks to Yahoo!7.
Enter now: http://au.docs.yahoo.com/homepageset/


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c20091113020824.GA2764@wladimir%3e"/>
<id>urn:uuid:%3c20091113020824-GA2764@wladimir%3e</id>
<updated>2009-11-13T02:08:24Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Trenton D. Adams schrieb am 12.11.2009 um 16:19:35 (-0700):
&gt; I didn't send an attachment, I sent a link.  Do links get removed too?

I must have been very tired when looking for the attachment.

&gt; As for it being 10k, the important part is that it does not work with
&gt; a processing instruction of "&lt;?xml-stylesheet...?&gt;", but does work
&gt; without one (i.e. specifying one in the java code).  It's not the
&gt; XML/XSLT that is important to look at, but the Java code, which is
&gt; very small, and easy to follow, especially considering it's a simple
&gt; JUnit test.

Maybe, but it is way more complex than it should have to be.

Anyway, I get two failures because of:

  junit.framework.AssertionFailedError
    caused by
  javax.xml.transform.TransformerException
    caused by
  java.net.UnknownHostException

And it is little wonder as your stylesheet PI misses a valid URI:

  &lt;?xml-stylesheet type="text/xsl"
    href="file://${basedir}/target/test-classes/transcript.xsl"?&gt;

Corrected this to:

  http://localhost/g/xml-util/target/test-classes/transcript.xsl

Now:

  junit.framework.AssertionFailedError
    caused by
  java.io.IOException: Stream closed

Okay, the error is in reading the PI from the StreamSource by calling
getAssociatedStylesheet(), and then trying to read again from the same
StreamSource by calling transform(). Streams are to be used once only.

Fixing this in your program is cumbersome, because you have one big
method with parameters of type Object which you then cast to whatever
you need based on what instanceof tells you.

  public static String xslTransformation(
    final Object xml,
    final Object xsl,
    final Map parameters )

What's wrong with using polymorphism instead? It's vastly superior.

Also, please consider providing simple test cases. You'd have discovered
this error yourself if you had taken the time to build a simple test
case without so many complicating ingredients. It bears repeating here
that simplifying is a basic problem solving technique.

Best,
-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>&quot;Trenton D. Adams&quot; &lt;trenta@athabascau.ca&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c1324889967.4426101258067975669.JavaMail.root@amundsen.cs.athabascau.ca%3e"/>
<id>urn:uuid:%3c1324889967-4426101258067975669-JavaMail-root@amundsen-cs-athabascau-ca%3e</id>
<updated>2009-11-12T23:19:35Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
I didn't send an attachment, I sent a link.  Do links get removed too?

http://         www.trentonadams.ca       /xml-util.tar.gz

As for it being 10k, the important part is that it does not work with a processing instruction
of "&lt;?xml-stylesheet...?&gt;", but does work without one (i.e. specifying one in the java
code).  It's not the XML/XSLT that is important to look at, but the Java code, which is very
small, and easy to follow, especially considering it's a simple JUnit test.

Thanks.

Trenton D. Adams
Systems Analyst/Web Software Engineer
Navy Penguins at your service!
Athabasca University
(780) 675-6195
:wq!

----- "Michael Ludwig" &lt;milu71@gmx.de&gt; wrote:

&gt; From: "Michael Ludwig" &lt;milu71@gmx.de&gt;
&gt; To: xalan-j-users@xml.apache.org
&gt; Sent: Wednesday, November 11, 2009 5:10:52 AM GMT -07:00 US/Canada Mountain
&gt; Subject: Re: Stream Closed on xsl transformation
&gt;
&gt; Trenton D. Adams schrieb am 07.11.2009 um 16:09:07 (-0700):
&gt; &gt; Hi Michael
&gt; &gt; 
&gt; &gt; Here is a 10K tar.gz file of a test case with a maven build
&gt; project.
&gt; 
&gt; Hi Trenton,
&gt; 
&gt; it looks like the attachment didn't make it to the list. Anyway, 10
&gt; KB
&gt; of gzipped text is not exactly small. I would have thought of a
&gt; simple
&gt; main() style test case.
&gt; 
&gt; Best,
&gt; 
&gt; -- 
&gt; Michael Ludwig

__ 
    This communication is intended for the use of the recipient to whom it
    is addressed, and may contain confidential, personal, and or privileged
    information. Please contact us immediately if you are not the intended
    recipient of this communication, and do not copy, distribute, or take
    action relying on it. Any communications received in error, or
    subsequent reply, should be deleted or destroyed.
---


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>Benson Margulies &lt;bimargulies@gmail.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c61b5d9410911111325l1d180f3cy8789e0f39ab346ce@mail.gmail.com%3e"/>
<id>urn:uuid:%3c61b5d9410911111325l1d180f3cy8789e0f39ab346ce@mail-gmail-com%3e</id>
<updated>2009-11-11T21:25:40Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Apache lists strip attachments. I suppose you could open a JIRA and attach
it there.

On Wed, Nov 11, 2009 at 7:10 AM, Michael Ludwig &lt;milu71@gmx.de&gt; wrote:

&gt; Trenton D. Adams schrieb am 07.11.2009 um 16:09:07 (-0700):
&gt; &gt; Hi Michael
&gt; &gt;
&gt; &gt; Here is a 10K tar.gz file of a test case with a maven build project.
&gt;
&gt; Hi Trenton,
&gt;
&gt; it looks like the attachment didn't make it to the list. Anyway, 10 KB
&gt; of gzipped text is not exactly small. I would have thought of a simple
&gt; main() style test case.
&gt;
&gt; Best,
&gt;
&gt; --
&gt; Michael Ludwig
&gt;


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: xml:base</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c20091111123519.GC2520@wladimir%3e"/>
<id>urn:uuid:%3c20091111123519-GC2520@wladimir%3e</id>
<updated>2009-11-11T12:35:19Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Jack Bates schrieb am 10.11.2009 um 13:08:16 (-0800):
&gt; 
&gt; When I pass a relative URL to the "document()" function, it resolved
&gt; to the wrong absolute URL, e.g. "/home/jablko/index.php"
&gt; 
&gt; So I tried using xml:base, e.g.

&gt;     &lt;xsl:apply-templates xml:base="http://ica-atom.org/docs/"
&gt;     select="document('index.php?title=User_manual')/html:html"/&gt;

&gt; ^ This works great with xsltproc,

&gt; - but not Xalan,

&gt; Is it a bug that Xalan appears to ignore xml:base?

Xalan claims to support XPath 1.0 and XSLT 1.0.

http://xml.apache.org/xalan-j/index.html

As far as I can see, Xalan makes no claim to supporting xml:base, which
is one of the add-ons to XML.

There is a Xalan bug pertaining to incorrect base URIs as a result of
failing to track the physical structure of an XML document (external
entities), which seems to support the above assessment, which I trust
the experts will correct if incorrect.

http://issues.apache.org/jira/browse/XALANJ-2274

&gt; Any advice on resolving relative URLs?

See javax.xml.transform.URIResolver. Implement and register your own URI
resolver.

Best,

-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c20091111121052.GB2520@wladimir%3e"/>
<id>urn:uuid:%3c20091111121052-GB2520@wladimir%3e</id>
<updated>2009-11-11T12:10:52Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Trenton D. Adams schrieb am 07.11.2009 um 16:09:07 (-0700):
&gt; Hi Michael
&gt; 
&gt; Here is a 10K tar.gz file of a test case with a maven build project.

Hi Trenton,

it looks like the attachment didn't make it to the list. Anyway, 10 KB
of gzipped text is not exactly small. I would have thought of a simple
main() style test case.

Best,

-- 
Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>xml:base</title>
<author><name>Jack Bates &lt;ms419@freezone.co.uk&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c1257887296.23183.3.camel@tad%3e"/>
<id>urn:uuid:%3c1257887296-23183-3-camel@tad%3e</id>
<updated>2009-11-10T21:08:16Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
I'm processing XML which contains relative URLs, e.g
"index.php?title=User_manual", and want to apply templates to the
referenced resources

I'm trying to do so with the "document()" function

When I pass a relative URL to the "document()" function, it resolved to
the wrong absolute URL, e.g. "/home/jablko/index.php"

So I tried using xml:base, e.g.

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:template match="/"&gt;
    &lt;xsl:apply-templates xml:base="http://ica-atom.org/docs/" select="document('index.php?title=User_manual')/html:html"/&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;

http://www.sfu.ca/~jdbates/tmp/xalan/200911090/test.xsl

^ This works great with xsltproc,

 $ xsltproc test.xsl test.xsl
 [...]
 $

- but not Xalan,

 $ java -jar xalan-j_2_7_1/xalan.jar -IN test.xsl -XSL test.xsl
 file:///home/jablko/test.xsl; Line #4; Column #123; Can not load requested doc: /home/jablko/index.php
(No such file or directory)
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;$ 

Any advice on resolving relative URLs?

Is it a bug that Xalan appears to ignore xml:base?


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>&quot;Trenton D. Adams&quot; &lt;trenta@athabascau.ca&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c479074118.3603001257637531959.JavaMail.root@amundsen.cs.athabascau.ca%3e"/>
<id>urn:uuid:%3c479074118-3603001257637531959-JavaMail-root@amundsen-cs-athabascau-ca%3e</id>
<updated>2009-11-07T23:45:32Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
I do have the java 1.4 restriction set in the pom, but I figured I'd give you my exact java
version...

java version "1.4.2-03"
Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.4.2-03)
Java HotSpot(TM) 64-Bit Server VM (build Blackdown-1.4.2-03, mixed mode)


Trenton D. Adams
Systems Analyst/Web Software Engineer
Navy Penguins at your service!
Athabasca University
(780) 675-6195
:wq!

----- "Trenton D. Adams" &lt;trenta@athabascau.ca&gt; wrote:

&gt; From: "Trenton D. Adams" &lt;trenta@athabascau.ca&gt;
&gt; To: "Michael Ludwig" &lt;milu71@gmx.de&gt;
&gt; Cc: xalan-j-users@xml.apache.org
&gt; Sent: Saturday, November 7, 2009 4:09:07 PM GMT -07:00 US/Canada Mountain
&gt; Subject: Re: Stream Closed on xsl transformation
&gt;
&gt; Hi Michael
&gt; 
&gt; Here is a 10K tar.gz file of a test case with a maven build project. 
&gt; Run with the "test" profile, as in...
&gt; 
&gt; mvn -P test install
&gt; 
&gt; The full stack trace is in xml-util.log.
&gt; 
&gt; Take note of the comment in XMLUtil.java:167, as I can get it to work
&gt; if I convert to a DOMSource instead.
&gt; 
&gt; http://www.trentonadams.ca/xml-util.tar.gz
&gt; 
&gt; Thanks.
&gt; 
&gt; Trenton D. Adams
&gt; Systems Analyst/Web Software Engineer
&gt; Navy Penguins at your service!
&gt; Athabasca University
&gt; (780) 675-6195
&gt; :wq!
&gt; 
&gt; ----- "Michael Ludwig" &lt;milu71@gmx.de&gt; wrote:
&gt; 
&gt; &gt; From: "Michael Ludwig" &lt;milu71@gmx.de&gt;
&gt; &gt; To: xalan-j-users@xml.apache.org
&gt; &gt; Sent: Thursday, November 5, 2009 6:08:04 PM GMT -07:00 US/Canada
&gt; Mountain
&gt; &gt; Subject: Re: Stream Closed on xsl transformation
&gt; &gt;
&gt; &gt; Hi Trenton,
&gt; &gt; 
&gt; &gt; Trenton D. Adams schrieb am 05.11.2009 um 13:00:00 (-0700):
&gt; &gt; 
&gt; &gt; &gt; I'm having some strange problems with a stream being closed when
&gt; I
&gt; &gt; do
&gt; &gt; &gt; an XSL transformation on an XML document that has an
&gt; xml-stylesheet
&gt; &gt; &gt; that is at a remote location.  If I instead put it locally, and
&gt; and
&gt; &gt; &gt; specify it as an xsltSource, it works fine.
&gt; &gt; &gt; 
&gt; &gt; &gt; I have also narrowed it down to the following working...
&gt; &gt; &gt;             final Document doc = stringToDocument((String) xml);
&gt; &gt; &gt;             logger.debug(documentToString(doc));
&gt; &gt; &gt;             xmlSource = new DOMSource(doc);
&gt; &gt; &gt; 
&gt; &gt; &gt; But not this...
&gt; &gt; &gt;             xmlSource = new StreamSource(new
&gt; StringReader((String)
&gt; &gt; xml));
&gt; &gt; 
&gt; &gt; This approach works fine for me as in:
&gt; &gt; 
&gt; &gt;   Source src = new StreamSource(new StringReader("&lt;Urmel/&gt;"));
&gt; &gt; 
&gt; &gt; &gt; I get a stack trace like the following; where the final "Caused
&gt; by"
&gt; &gt; &gt; indicates it has a problem with the StringReader in the second
&gt; &gt; example
&gt; &gt; &gt; above.  But, my stringToDocument() method also does a
&gt; StringReader.
&gt; &gt; 
&gt; &gt; &gt; Caused by: java.io.IOException: Stream closed                     
&gt;  
&gt; &gt;                                                
&gt; &gt; &gt;         at java.io.StringReader.ensureOpen(StringReader.java:39)  
&gt;  
&gt; &gt;                                                
&gt; &gt; &gt;         at java.io.StringReader.read(StringReader.java:73)        
&gt;  
&gt; &gt;                                                
&gt; &gt; &gt;         at
&gt; &gt;
&gt; org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3257)
&gt; &gt; 
&gt; &gt; The exception seems to occur in a large program. There must be
&gt; &gt; something
&gt; &gt; wrong in those lines that you haven't shown. Rather than posting
&gt; the
&gt; &gt; massive program, try boiling it down to a small, self-contained
&gt; test
&gt; &gt; case. If the error persists, you might want to post the small test
&gt; &gt; program.
&gt; &gt; 
&gt; &gt; Best,
&gt; &gt; 
&gt; &gt; Michael Ludwig
&gt; 
&gt; __ 
&gt;     This communication is intended for the use of the recipient to
&gt; whom it
&gt;     is addressed, and may contain confidential, personal, and or
&gt; privileged
&gt;     information. Please contact us immediately if you are not the
&gt; intended
&gt;     recipient of this communication, and do not copy, distribute, or
&gt; take
&gt;     action relying on it. Any communications received in error, or
&gt;     subsequent reply, should be deleted or destroyed.
&gt; ---


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>&quot;Trenton D. Adams&quot; &lt;trenta@athabascau.ca&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c1774923162.3602441257635347939.JavaMail.root@amundsen.cs.athabascau.ca%3e"/>
<id>urn:uuid:%3c1774923162-3602441257635347939-JavaMail-root@amundsen-cs-athabascau-ca%3e</id>
<updated>2009-11-07T23:09:07Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi Michael

Here is a 10K tar.gz file of a test case with a maven build project.  Run with the "test"
profile, as in...

mvn -P test install

The full stack trace is in xml-util.log.

Take note of the comment in XMLUtil.java:167, as I can get it to work if I convert to a DOMSource
instead.

http://www.trentonadams.ca/xml-util.tar.gz

Thanks.

Trenton D. Adams
Systems Analyst/Web Software Engineer
Navy Penguins at your service!
Athabasca University
(780) 675-6195
:wq!

----- "Michael Ludwig" &lt;milu71@gmx.de&gt; wrote:

&gt; From: "Michael Ludwig" &lt;milu71@gmx.de&gt;
&gt; To: xalan-j-users@xml.apache.org
&gt; Sent: Thursday, November 5, 2009 6:08:04 PM GMT -07:00 US/Canada Mountain
&gt; Subject: Re: Stream Closed on xsl transformation
&gt;
&gt; Hi Trenton,
&gt; 
&gt; Trenton D. Adams schrieb am 05.11.2009 um 13:00:00 (-0700):
&gt; 
&gt; &gt; I'm having some strange problems with a stream being closed when I
&gt; do
&gt; &gt; an XSL transformation on an XML document that has an xml-stylesheet
&gt; &gt; that is at a remote location.  If I instead put it locally, and and
&gt; &gt; specify it as an xsltSource, it works fine.
&gt; &gt; 
&gt; &gt; I have also narrowed it down to the following working...
&gt; &gt;             final Document doc = stringToDocument((String) xml);
&gt; &gt;             logger.debug(documentToString(doc));
&gt; &gt;             xmlSource = new DOMSource(doc);
&gt; &gt; 
&gt; &gt; But not this...
&gt; &gt;             xmlSource = new StreamSource(new StringReader((String)
&gt; xml));
&gt; 
&gt; This approach works fine for me as in:
&gt; 
&gt;   Source src = new StreamSource(new StringReader("&lt;Urmel/&gt;"));
&gt; 
&gt; &gt; I get a stack trace like the following; where the final "Caused by"
&gt; &gt; indicates it has a problem with the StringReader in the second
&gt; example
&gt; &gt; above.  But, my stringToDocument() method also does a StringReader.
&gt; 
&gt; &gt; Caused by: java.io.IOException: Stream closed                       
&gt;                                                
&gt; &gt;         at java.io.StringReader.ensureOpen(StringReader.java:39)    
&gt;                                                
&gt; &gt;         at java.io.StringReader.read(StringReader.java:73)          
&gt;                                                
&gt; &gt;         at
&gt; org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3257)
&gt; 
&gt; The exception seems to occur in a large program. There must be
&gt; something
&gt; wrong in those lines that you haven't shown. Rather than posting the
&gt; massive program, try boiling it down to a small, self-contained test
&gt; case. If the error persists, you might want to post the small test
&gt; program.
&gt; 
&gt; Best,
&gt; 
&gt; Michael Ludwig

__ 
    This communication is intended for the use of the recipient to whom it
    is addressed, and may contain confidential, personal, and or privileged
    information. Please contact us immediately if you are not the intended
    recipient of this communication, and do not copy, distribute, or take
    action relying on it. Any communications received in error, or
    subsequent reply, should be deleted or destroyed.
---


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>&quot;Trenton D. Adams&quot; &lt;trenta@athabascau.ca&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c1503985958.3379301257490248028.JavaMail.root@amundsen.cs.athabascau.ca%3e"/>
<id>urn:uuid:%3c1503985958-3379301257490248028-JavaMail-root@amundsen-cs-athabascau-ca%3e</id>
<updated>2009-11-06T06:50:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi Michael,

----- "Michael Ludwig" &lt;milu71@gmx.de&gt; wrote:

&gt; From: "Michael Ludwig" &lt;milu71@gmx.de&gt;
&gt; To: xalan-j-users@xml.apache.org
&gt; Sent: Thursday, November 5, 2009 6:08:04 PM GMT -07:00 US/Canada Mountain
&gt; Subject: Re: Stream Closed on xsl transformation
&gt;
&gt; Hi Trenton,
&gt; 
&gt; Trenton D. Adams schrieb am 05.11.2009 um 13:00:00 (-0700):
&gt; 
&gt; &gt; I'm having some strange problems with a stream being closed when I
&gt; do
&gt; &gt; an XSL transformation on an XML document that has an xml-stylesheet
&gt; &gt; that is at a remote location.  If I instead put it locally, and and
&gt; &gt; specify it as an xsltSource, it works fine.
&gt; &gt; 
&gt; &gt; I have also narrowed it down to the following working...
&gt; &gt;             final Document doc = stringToDocument((String) xml);
&gt; &gt;             logger.debug(documentToString(doc));
&gt; &gt;             xmlSource = new DOMSource(doc);
&gt; &gt; 
&gt; &gt; But not this...
&gt; &gt;             xmlSource = new StreamSource(new StringReader((String)
&gt; xml));
&gt; 
&gt; This approach works fine for me as in:
&gt; 
&gt;   Source src = new StreamSource(new StringReader("&lt;Urmel/&gt;"));

Yeah, that wouldn't be a problem, as it does not have an xml-stylesheet processing instruction.

&gt; 
&gt; &gt; I get a stack trace like the following; where the final "Caused by"
&gt; &gt; indicates it has a problem with the StringReader in the second
&gt; example
&gt; &gt; above.  But, my stringToDocument() method also does a StringReader.
&gt; 
&gt; &gt; Caused by: java.io.IOException: Stream closed                       
&gt;                                                
&gt; &gt;         at java.io.StringReader.ensureOpen(StringReader.java:39)    
&gt;                                                
&gt; &gt;         at java.io.StringReader.read(StringReader.java:73)          
&gt;                                                
&gt; &gt;         at
&gt; org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3257)
&gt; 
&gt; The exception seems to occur in a large program. There must be
&gt; something
&gt; wrong in those lines that you haven't shown. Rather than posting the
&gt; massive program, try boiling it down to a small, self-contained test
&gt; case. If the error persists, you might want to post the small test
&gt; program.

Yes, I did narrow it down to a small test case (or semi-small, the xml/xslt isn't so small).
 I will see if I can provide it when I get to work tomorrow.  I'll also see if I can make
it happen with a smaller XML/XSLT.

&gt; 
&gt; Best,
&gt; 
&gt; Michael Ludwig

__ 
    This communication is intended for the use of the recipient to whom it
    is addressed, and may contain confidential, personal, and or privileged
    information. Please contact us immediately if you are not the intended
    recipient of this communication, and do not copy, distribute, or take
    action relying on it. Any communications received in error, or
    subsequent reply, should be deleted or destroyed.
---


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Stream Closed on xsl transformation</title>
<author><name>Michael Ludwig &lt;milu71@gmx.de&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c20091106010804.GC508@wladimir%3e"/>
<id>urn:uuid:%3c20091106010804-GC508@wladimir%3e</id>
<updated>2009-11-06T01:08:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi Trenton,

Trenton D. Adams schrieb am 05.11.2009 um 13:00:00 (-0700):

&gt; I'm having some strange problems with a stream being closed when I do
&gt; an XSL transformation on an XML document that has an xml-stylesheet
&gt; that is at a remote location.  If I instead put it locally, and and
&gt; specify it as an xsltSource, it works fine.
&gt; 
&gt; I have also narrowed it down to the following working...
&gt;             final Document doc = stringToDocument((String) xml);
&gt;             logger.debug(documentToString(doc));
&gt;             xmlSource = new DOMSource(doc);
&gt; 
&gt; But not this...
&gt;             xmlSource = new StreamSource(new StringReader((String) xml));

This approach works fine for me as in:

  Source src = new StreamSource(new StringReader("&lt;Urmel/&gt;"));

&gt; I get a stack trace like the following; where the final "Caused by"
&gt; indicates it has a problem with the StringReader in the second example
&gt; above.  But, my stringToDocument() method also does a StringReader.

&gt; Caused by: java.io.IOException: Stream closed                                       
                               
&gt;         at java.io.StringReader.ensureOpen(StringReader.java:39)                    
                               
&gt;         at java.io.StringReader.read(StringReader.java:73)                          
                               
&gt;         at org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3257)

The exception seems to occur in a large program. There must be something
wrong in those lines that you haven't shown. Rather than posting the
massive program, try boiling it down to a small, self-contained test
case. If the error persists, you might want to post the small test
program.

Best,

Michael Ludwig


</pre>
</div>
</content>
</entry>
<entry>
<title>Stream Closed on xsl transformation</title>
<author><name>&quot;Trenton D. Adams&quot; &lt;trenta@athabascau.ca&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c1048198835.3244951257451200612.JavaMail.root@amundsen.cs.athabascau.ca%3e"/>
<id>urn:uuid:%3c1048198835-3244951257451200612-JavaMail-root@amundsen-cs-athabascau-ca%3e</id>
<updated>2009-11-05T20:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi Guys,

I'm having some strange problems with a stream being closed when I do an XSL transformation
on an XML document that has an xml-stylesheet that is at a remote location.  If I instead
put it locally, and and specify it as an xsltSource, it works fine.

I have also narrowed it down to the following working...
            final Document doc = stringToDocument((String) xml);
            logger.debug(documentToString(doc));
            xmlSource = new DOMSource(doc);

But not this...
            xmlSource = new StreamSource(new StringReader((String) xml));

Any ideas why this wouldn't work?

I get a stack trace like the following; where the final "Caused by" indicates it has a problem
with the StringReader in the second example above.  But, my stringToDocument() method also
does a StringReader.

Caused by: javax.xml.transform.TransformerException: java.io.IOException: Stream closed  
                          
        at org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java:741)
                       
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:715)
                        
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
                       
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
                       
        at ca.athabascau.apas.xml.XMLUtil.xslTransformation(XMLUtil.java:226)            
                          
        at ca.athabascau.apas.xml.XMLUtil.xslTransformation(XMLUtil.java:251)            
                          
        at ca.athabascau.apas.IncomingTranscripts.processTranscript(IncomingTranscripts.java:348)
                  
        at ca.athabascau.apas.IncomingTranscripts.processWaitingTranscripts(IncomingTranscripts.java:107)
          
        ... 28 more                                                                      
                          
Caused by: java.io.IOException: Stream closed                                            
                          
        at java.io.StringReader.ensureOpen(StringReader.java:39)                         
                          
        at java.io.StringReader.read(StringReader.java:73)                               
                          
        at org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3257)
                  
        at org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipString(XMLEntityManager.java:3017)
            
        at org.apache.xerces.impl.XMLDocumentScannerImpl$XMLDeclDispatcher.dispatch(XMLDocumentScannerImpl.java:577)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
                                                                                         
                       
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:524)   
                          
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:580)   
                          
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)                 
                          
        at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1169)
                          
        at org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:495)   
                          
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:658)
                        
        ... 34 more                                                                      
                         


Trenton D. Adams
Systems Analyst/Web Software Engineer
Navy Penguins at your service!
Athabasca University
(780) 675-6195
:wq!

__ 
    This communication is intended for the use of the recipient to whom it
    is addressed, and may contain confidential, personal, and or privileged
    information. Please contact us immediately if you are not the intended
    recipient of this communication, and do not copy, distribute, or take
    action relying on it. Any communications received in error, or
    subsequent reply, should be deleted or destroyed.
---


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: Missing xpath method error from some classpath disaster or another</title>
<author><name>Santiago Pericas-Geertsen &lt;Santiago.Pericasgeertsen@Sun.COM&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cFF344793-9BCF-4646-82E4-C43B8F006A9B@sun.com%3e"/>
<id>urn:uuid:%3cFF344793-9BCF-4646-82E4-C43B8F006A9B@sun-com%3e</id>
<updated>2009-11-04T14:41:16Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Benson,

  This could happen if Tomcat is bundling a different version of Xalan  
than the one you used to compile your webapp. You should check that.  
You can always bundle your own version of Xalan if classloading is set  
to support that in Tomcat. The Tomcat user list may be able to help  
you with that.

-- Santiago

On Nov 4, 2009, at 8:34 AM, Benson Margulies wrote:

&gt; I can provoke the following by trying to use Xalan inside of a Webapp
&gt; inside of Tomcat after using the JAXP 1.4 explicit newInstance to
&gt; obtain my factory. Confused doesn't begin to describe my reaction. Can
&gt; anyone give me a clue? Or a diagnostic procedure?
&gt;
&gt; java.lang.NoSuchMethodError: org.apache.xpath.XPathContext.&lt;init&gt;(Z)V
&gt; 	org.apache.xpath.jaxp.XPathImpl.eval(XPathImpl.java:207)
&gt; 	org.apache.xpath.jaxp.XPathImpl.evaluate(XPathImpl.java:281)
&gt; 	org.apache.mtomcatbug.Serviette.doGet(Serviette.java:58)
&gt; 	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
&gt; 	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)



</pre>
</div>
</content>
</entry>
<entry>
<title>Missing xpath method error from some classpath disaster or another</title>
<author><name>Benson Margulies &lt;bimargulies@gmail.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c61b5d9410911040534wd75e152y38640ef0bcbe998@mail.gmail.com%3e"/>
<id>urn:uuid:%3c61b5d9410911040534wd75e152y38640ef0bcbe998@mail-gmail-com%3e</id>
<updated>2009-11-04T13:34:31Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
I can provoke the following by trying to use Xalan inside of a Webapp
inside of Tomcat after using the JAXP 1.4 explicit newInstance to
obtain my factory. Confused doesn't begin to describe my reaction. Can
anyone give me a clue? Or a diagnostic procedure?

java.lang.NoSuchMethodError: org.apache.xpath.XPathContext.&lt;init&gt;(Z)V
	org.apache.xpath.jaxp.XPathImpl.eval(XPathImpl.java:207)
	org.apache.xpath.jaxp.XPathImpl.evaluate(XPathImpl.java:281)
	org.apache.mtomcatbug.Serviette.doGet(Serviette.java:58)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How can I pass a node as parameter to translets for XSLTC-Processor</title>
<author><name>EddyXSL &lt;eddy.fras@free.fr&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3c26160041.post@talk.nabble.com%3e"/>
<id>urn:uuid:%3c26160041-post@talk-nabble-com%3e</id>
<updated>2009-11-03T09:55:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

Hi amitdk,

I tried to use your solution to pass a node-set to a translet and I don't
understand why, it does not work.
It's very strange but when I navigate in the node-set parameter, I get the
nodes of the XML source tree instead ! When I use a debugger, the
DTMAxisIterator passed as parameter seems ok, it contains in some deep
fields the content of the XML fragment I want to pass as parameter.
But I have to admit that understand how DTMxxx classes work is a real
nightmare for me.

Anyway, I don't understand why the official answer to this node-set
parameter passing problem is "known issue for XSLTC". When we have a look at
the BasisLibrary Xalan class, we can see that the referenceToNodeSet method
(called when a parameter is a node-set) exists and does some stuff to get a
DTMAxisIterator from either a org.apache.xalan.xsltc.runtime.Node (really
don't understand how to get this kind of object) or a DTMAxisIterator by
cloning it.
That means for me that the feature is available, am I wrong ?

Thanks for your help,

Eddy


amitdk wrote:
&gt; 
&gt; Return DTMAxisIterator instead of XNodeSet. That should help solve the
&gt; issue. Here's the method I use to convert a Document object and pass it as
&gt; a parameter to the translet.
&gt; 
&gt;     private DTMAxisIterator convertDocumentToNodeSet(Document document)
&gt; throws TransformerException
&gt;     {
&gt;         
&gt;         DOMSource domSource = new DOMSource(document);
&gt;         XSLTCDTMManager mgr = new XSLTCDTMManager();
&gt;         DTM dtm = mgr.getDTM(domSource, false, null, true, true);
&gt;         int dtmRoot = dtm.getDocument();
&gt;         DTMAxisIterator iter = dtm.getAxisIterator(Axis.SELF);
&gt;         iter.setStartNode(dtmRoot);
&gt;         
&gt;         return iter;
&gt;     }
&gt; 

-- 
View this message in context: http://old.nabble.com/How-can-I-pass-a-node-as-parameter-to-translets-for-XSLTC-Processor-tp8649149p26160041.html
Sent from the Xalan - J - Users mailing list archive at Nabble.com.



</pre>
</div>
</content>
</entry>
<entry>
<title>Re: How to pass java.util.Map instance as a parameter to a XSLTStylesheet</title>
<author><name>Santiago Pericas-Geertsen &lt;Santiago.Pericasgeertsen@Sun.COM&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cB76B904E-4826-449C-84C9-720F8BA6FBC0@sun.com%3e"/>
<id>urn:uuid:%3cB76B904E-4826-449C-84C9-720F8BA6FBC0@sun-com%3e</id>
<updated>2009-11-02T14:01:52Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Vishal,

  Xalan in the JDK is a compiler (XSLTC) and as such it tries to  
resolve as much as it can statically. As a result, there are some  
limitations. The discussion and resolution in [1] may help.

-- Santiago

[1] http://issues.apache.org/jira/browse/XALANJ-1485

On Nov 2, 2009, at 7:21 AM, Javalkar, Vishal wrote:

&gt; Hi,
&gt;
&gt; Apparently, Xalan (the one bundled with JDK 6 at-least) complains  
&gt; when a java.util.Map is passed as a parameter to an XSLT stylesheet.
&gt;
&gt; Assuming, I have a snippet of code as:
&gt;
&gt; Map inputparam = new HashMap();	
&gt; inputparam.put("greeting", "hi there");
&gt; transformer.setParameter("inputparam", inputparam);
&gt; ...
&gt; transformer.transform(...);
&gt;
&gt; and I have a simple XSLT that attempts to get the key 'greeting'  
&gt; from this
&gt;
&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&gt; &lt;xsl:stylesheet version="1.0"
&gt; 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
&gt; 	xmlns:map="xalan://java.util.HashMap"
&gt; 	extension-element-prefixes="map"&gt;
&gt; 	
&gt; 	&lt;xsl:param name="inputparam" /&gt;
&gt; 	
&gt; 	&lt;xsl:template match="/"&gt;
&gt; 		&lt;xsl:variable name="greeting"
&gt; 			select="map:get($inputparam, 'greeting')" /&gt;
&gt; 		&lt;greeting&gt;&lt;xsl:value-of select="greeting"/&gt;&lt;/greeting&gt;		
&gt; 	&lt;/xsl:template&gt;
&gt; &lt;/xsl:stylesheet&gt;
&gt;
&gt; I obtain the following error:
&gt;
&gt; ERROR:  'Cannot find external method 'java.util.HashMap.get' (must  
&gt; be public).'
&gt; FATAL ERROR:  'Could not compile stylesheet'
&gt; javax.xml.transform.TransformerConfigurationException: Could not  
&gt; compile stylesheet
&gt; 	at  
&gt; com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates 
&gt; (TransformerFactoryImpl.java:825)
&gt; 	at  
&gt; com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer 
&gt; (TransformerFactoryImpl.java:614)
&gt; 	at xalanxslttest.ExecuteXslt.main(ExecuteXslt.java:36)
&gt;
&gt;
&gt; Is there a way to solve this? Is this supported?
&gt;
&gt; All help/advice appreciated!
&gt; Thanks &amp; Regards,
&gt; Vishal
&gt;



</pre>
</div>
</content>
</entry>
<entry>
<title>How to pass java.util.Map instance as a parameter to a XSLTStylesheet</title>
<author><name>&quot;Javalkar, Vishal&quot; &lt;vishal.javalkar@sap.com&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200911.mbox/%3cDC7218B52792D340B42F0874857165162EC58EB5A7@DEWDFECCR06.wdf.sap.corp%3e"/>
<id>urn:uuid:%3cDC7218B52792D340B42F0874857165162EC58EB5A7@DEWDFECCR06-wdf-sap-corp%3e</id>
<updated>2009-11-02T12:21:39Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Hi,

Apparently, Xalan (the one bundled with JDK 6 at-least) complains when a java.util.Map is
passed as a parameter to an XSLT stylesheet. 

Assuming, I have a snippet of code as:

Map inputparam = new HashMap();	
inputparam.put("greeting", "hi there");
transformer.setParameter("inputparam", inputparam);
...
transformer.transform(...);

and I have a simple XSLT that attempts to get the key 'greeting' from this

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:map="xalan://java.util.HashMap"
	extension-element-prefixes="map"&gt;
	
	&lt;xsl:param name="inputparam" /&gt;
	
	&lt;xsl:template match="/"&gt;
		&lt;xsl:variable name="greeting"
			select="map:get($inputparam, 'greeting')" /&gt;
		&lt;greeting&gt;&lt;xsl:value-of select="greeting"/&gt;&lt;/greeting&gt;		
	&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;

I obtain the following error:

ERROR:  'Cannot find external method 'java.util.HashMap.get' (must be public).'
FATAL ERROR:  'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:825)
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:614)
	at xalanxslttest.ExecuteXslt.main(ExecuteXslt.java:36)


Is there a way to solve this? Is this supported?

All help/advice appreciated!
Thanks &amp; Regards,
Vishal



</pre>
</div>
</content>
</entry>
</feed>
