Discussion:
XSLT with entities and therefore DOCTYPE
Mike Castle
2003-12-08 20:23:16 UTC
Permalink
I'm not sure if this is something that can be answered on this list. I'm
hoping that at least I can be pointing to a better place to ask.

I'm delving into XSLT and have developed a transformation that works well
when I use it against xsltproc on my Linux box. So I want to migrate this
to ant to be part of our build process, and I'm running across errors.

In particular, this example works well:

demo.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
test
</xsl:template>
</xsl:stylesheet>

and from build.xml:
<target name="xslttest">
<xslt in="build.xml" out="results.txt" style="demo.xsl"/>
</target>

Now, in my real version, I need to use entities, so I change it to
something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "test">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
&foo;
</xsl:template>
</xsl:stylesheet>

Which works fine with xsltproc, but ant 1.5.3 gives me:

xslttest:
[xslt] Processing /homedir/mcastle/build.xml to /homedir/mcastle/results.txt
[xslt] Loading stylesheet /homedir/mcastle/demo.xsl
[xslt] [Error] demo.xsl:5:80: Element type "xsl:stylesheet" must be declared.
[xslt] [Error] demo.xsl:6:27: Element type "xsl:template" must be declared.

BUILD SUCCESSFUL

Now, it turns out that results.txt actually holds the correct text, which
is great. But that is an awful lot of noise on the screen, particularly
when my real case is much larger. And that noise is distracting.

So, I've been trying to experiment with xsl:variable, but to no luck. For
example, I really need to do something like the following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="foo">[test]</xsl:variable>
<xsl:variable name="bar" select="/project/target$foo"/>
<xsl:value-of select="$bar"/>
</xsl:template>
</xsl:stylesheet>

And I've tried several variations on this technique to no avail.

So, is there anyway I can get ant to convince XSLT not to validate the
stylesheet, even though it has a DOCTYPE (I really don't want to have to
write a DTD for this thing)?

Or would anyone know how to hammer xsl:variables into doing what I want?

Outside of that, where do I go to ask for help (specifically, what would
YOU recommend)? My searches really haven't turned up too much useful
information, but I'm new enough to this that I am probably missing useful
terms that would help.

Thanks a lot,
mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
Antoine Lévy-Lambert
2003-12-08 20:46:12 UTC
Permalink
Hi Mike,

I am no great XSL expert.

Did you try the <xsl:import/> element instead of entities ?
Maybe you are having problems with the xml-apis.jar or the xercesImpl.jar
which is bundled with ant 1.5.3 ?
I am not sure, I hope someone else gives you better ideas.
Otherwise, there are certainly some xml lists where you could ask too.
BTW : the address of this mailing list is ***@ant.apache.org
Cheers,
Antoine

-----Ursprüngliche Nachricht-----
Von: Mike Castle [mailto:***@ix.netcom.com]
Gesendet: Montag, 8. Dezember 2003 21:23
An: ant-***@jakarta.apache.org
Betreff: XSLT with entities and therefore DOCTYPE



I'm not sure if this is something that can be answered on this list. I'm
hoping that at least I can be pointing to a better place to ask.

I'm delving into XSLT and have developed a transformation that works well
when I use it against xsltproc on my Linux box. So I want to migrate this
to ant to be part of our build process, and I'm running across errors.

In particular, this example works well:

demo.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
test
</xsl:template>
</xsl:stylesheet>

and from build.xml:
<target name="xslttest">
<xslt in="build.xml" out="results.txt" style="demo.xsl"/>
</target>

Now, in my real version, I need to use entities, so I change it to
something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "test">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
&foo;
</xsl:template>
</xsl:stylesheet>

Which works fine with xsltproc, but ant 1.5.3 gives me:

xslttest:
[xslt] Processing /homedir/mcastle/build.xml to
/homedir/mcastle/results.txt
[xslt] Loading stylesheet /homedir/mcastle/demo.xsl
[xslt] [Error] demo.xsl:5:80: Element type "xsl:stylesheet" must be
declared.
[xslt] [Error] demo.xsl:6:27: Element type "xsl:template" must be
declared.

BUILD SUCCESSFUL

Now, it turns out that results.txt actually holds the correct text, which
is great. But that is an awful lot of noise on the screen, particularly
when my real case is much larger. And that noise is distracting.

So, I've been trying to experiment with xsl:variable, but to no luck. For
example, I really need to do something like the following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="foo">[test]</xsl:variable>
<xsl:variable name="bar" select="/project/target$foo"/>
<xsl:value-of select="$bar"/>
</xsl:template>
</xsl:stylesheet>

And I've tried several variations on this technique to no avail.

So, is there anyway I can get ant to convince XSLT not to validate the
stylesheet, even though it has a DOCTYPE (I really don't want to have to
write a DTD for this thing)?

Or would anyone know how to hammer xsl:variables into doing what I want?

Outside of that, where do I go to ask for help (specifically, what would
YOU recommend)? My searches really haven't turned up too much useful
information, but I'm new enough to this that I am probably missing useful
terms that would help.

Thanks a lot,
mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); --
gcc
Robert Koberg
2003-12-08 21:10:05 UTC
Permalink
Post by Antoine Lévy-Lambert
-----Ursprüngliche Nachricht-----
Gesendet: Montag, 8. Dezember 2003 21:23
Betreff: XSLT with entities and therefore DOCTYPE
<snip/>

There is the mulberrytech xsl-list that is a very good resource. I will
try to answer inline. Also, get a copy of Mike Kay's XSLT Programmer's
Reference 2cnd edition (the bible for xsl).
Post by Antoine Lévy-Lambert
So, I've been trying to experiment with xsl:variable, but to no luck. For
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="foo">[test]</xsl:variable>
<xsl:variable name="bar" select="/project/target$foo"/>
This might be a typo..................................^

I am not clear on what you are trying to do, but here are some ideas.

Are you trying to hold a string in this variable? If so, you need to put
the string in quotes:

<xsl:variable name="bar" select="concat('/project/target/', $foo)"/>

Are you trying to access something like:

<project>
<target>
[test]
</target>
</project>

then:

<xsl:variable name="bar" select="normalize-space(/project/target)"/>

Are you trying to build an XPath on the fly to access something like:


<project>
<target>
<test boo="something"/>
</target>
</project>

then:

<xsl:variable
name="bar"
Post by Antoine Lévy-Lambert
<xsl:value-of select="$bar"/>
</xsl:template>
</xsl:stylesheet>
And I've tried several variations on this technique to no avail.
So, is there anyway I can get ant to convince XSLT not to validate the
stylesheet, even though it has a DOCTYPE (I really don't want to have to
write a DTD for this thing)?
don't use a DTD for this.
Post by Antoine Lévy-Lambert
Or would anyone know how to hammer xsl:variables into doing what I want?
don't know what you want.
Post by Antoine Lévy-Lambert
Outside of that, where do I go to ask for help (specifically, what would
YOU recommend)? My searches really haven't turned up too much useful
information, but I'm new enough to this that I am probably missing useful
terms that would help.
see above

best,
-Rob
Post by Antoine Lévy-Lambert
Thanks a lot,
mrc
--
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); --
gcc
Mike Castle
2003-12-10 00:33:53 UTC
Permalink
Post by Robert Koberg
Post by Antoine Lévy-Lambert
-----Ursprüngliche Nachricht-----
Gesendet: Montag, 8. Dezember 2003 21:23
There is the mulberrytech xsl-list that is a very good resource. I will
Yeah, that site came up a lot when I was trying to figure this out before I
posted. Unfortunately none of the posts in the archived seemed to directly
address my issue, however (at least that I saw).
Post by Robert Koberg
try to answer inline. Also, get a copy of Mike Kay's XSLT Programmer's
Reference 2cnd edition (the bible for xsl).
Our office copy seems to have wandered off. :-/
Post by Robert Koberg
Post by Antoine Lévy-Lambert
So, I've been trying to experiment with xsl:variable, but to no luck. For
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="foo">[test]</xsl:variable>
<xsl:variable name="bar" select="/project/target$foo"/>
This might be a typo..................................^
Nope. Not a typo.

If foo is an entity, then that turns out looking like
"/project/target[test]" which is what I want.

That is, I want a node-set of /project/target's that have an element
test in them. Now, in the real life example, the predicate isn't a simple
``test'' but rather an 80 character long string that I need to use several
times in different contexts.
Post by Robert Koberg
I am not clear on what you are trying to do, but here are some ideas.
Are you trying to hold a string in this variable? If so, you need to put
<xsl:variable name="bar" select="concat('/project/target/', $foo)"/>
Ok, I tried something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="targets-with-echos" select="/project/target[echo]"/>
<xsl:number value="count($targets-with-echos)"/>
</xsl:template>
</xsl:stylesheet>

I then changed it to this:


<xsl:variable name="targets-with-echos" select="concat('/project/target','[echo]')"/>

[xslt] homedir/mcastle/demo.xsl:5:53: Error! Can not convert #STRING to a NodeList!
[xslt] homedir/mcastle/demo.xsl:5:53: Fatal Error! java.lang.NullPointerException Cause: java.lang.NullPointerException

And looking that up seems to indicate that it's simply not possible to do
something like this in standard xslt.
Post by Robert Koberg
Post by Antoine Lévy-Lambert
So, is there anyway I can get ant to convince XSLT not to validate the
stylesheet, even though it has a DOCTYPE (I really don't want to have to
write a DTD for this thing)?
don't use a DTD for this.
Right. I don't want to. However, how can I get the XML parser to not
complain about the .xsl file though?
Post by Robert Koberg
Post by Antoine Lévy-Lambert
Or would anyone know how to hammer xsl:variables into doing what I want?
don't know what you want.
I don't want to have to type this in multiple places:

LogRecord[@severity='MFATAL' or @severity='FATAL' or contains(text(),'Exception')]

Because that will change over time, and I want to reduce the chances that
I'll mess it up in one of the locations.

mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
Will Lopez
2003-12-08 21:41:31 UTC
Permalink
A very good XSL list is xsl-***@lists.mulberrytech.com.

I don't understand what you're trying to accomplish...can you supply the
result you expect (and the input)...real code...this example only has a
template to match the root node and it will depend on the built in
templates to process the remaining nodes...also, you may just need a
variable.

Your'e stylesheet declaration is incorrect...see below...

Try changing your code from this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "test">
...


...to this **NOT TESTED** -it's been a while since I used XSLT but
there are tons of resources on the web...
http://www.w3schools.com/xsl/default.asp
http://www.w3.org/TR/xslt - W3C spec
http://www.zvon.org/HTMLonly/XSLTutorial/Books/Book1/index.html - check
this site out

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!ENTITY foo "test">
...

..or if you want to use a variable substitute the ENTITY declaration
with this:

<xsl:variable name="foo" select="'test'" /> (makes it global due to the declaration spot)
then refer to it by using $foo

HTH,
-Will
Post by Antoine Lévy-Lambert
Hi Mike,
I am no great XSL expert.
Did you try the <xsl:import/> element instead of entities ?
Maybe you are having problems with the xml-apis.jar or the xercesImpl.jar
which is bundled with ant 1.5.3 ?
I am not sure, I hope someone else gives you better ideas.
Otherwise, there are certainly some xml lists where you could ask too.
Cheers,
Antoine
-----Ursprüngliche Nachricht-----
Gesendet: Montag, 8. Dezember 2003 21:23
Betreff: XSLT with entities and therefore DOCTYPE
I'm not sure if this is something that can be answered on this list. I'm
hoping that at least I can be pointing to a better place to ask.
I'm delving into XSLT and have developed a transformation that works well
when I use it against xsltproc on my Linux box. So I want to migrate this
to ant to be part of our build process, and I'm running across errors.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
test
</xsl:template>
</xsl:stylesheet>
<target name="xslttest">
<xslt in="build.xml" out="results.txt" style="demo.xsl"/>
</target>
Now, in my real version, I need to use entities, so I change it to
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "test">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
&foo;
</xsl:template>
</xsl:stylesheet>
[xslt] Processing /homedir/mcastle/build.xml to
/homedir/mcastle/results.txt
[xslt] Loading stylesheet /homedir/mcastle/demo.xsl
[xslt] [Error] demo.xsl:5:80: Element type "xsl:stylesheet" must be
declared.
[xslt] [Error] demo.xsl:6:27: Element type "xsl:template" must be
declared.
BUILD SUCCESSFUL
Now, it turns out that results.txt actually holds the correct text, which
is great. But that is an awful lot of noise on the screen, particularly
when my real case is much larger. And that noise is distracting.
So, I've been trying to experiment with xsl:variable, but to no luck. For
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="foo">[test]</xsl:variable>
<xsl:variable name="bar" select="/project/target$foo"/>
<xsl:value-of select="$bar"/>
</xsl:template>
</xsl:stylesheet>
And I've tried several variations on this technique to no avail.
So, is there anyway I can get ant to convince XSLT not to validate the
stylesheet, even though it has a DOCTYPE (I really don't want to have to
write a DTD for this thing)?
Or would anyone know how to hammer xsl:variables into doing what I want?
Outside of that, where do I go to ask for help (specifically, what would
YOU recommend)? My searches really haven't turned up too much useful
information, but I'm new enough to this that I am probably missing useful
terms that would help.
Thanks a lot,
mrc
--
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); --
gcc
---------------------------------------------------------------------
Mike Castle
2003-12-10 01:34:16 UTC
Permalink
Unfortunately, when I checked the archives (prior to posting here), I was
unable to find anything directly addressing my real issue (which is the
parser yelling at me for no reason).
Post by Will Lopez
I don't understand what you're trying to accomplish...can you supply the
result you expect (and the input)...real code...this example only has a
template to match the root node and it will depend on the built in
templates to process the remaining nodes...also, you may just need a
variable.
Ok. Here.

***@dl-mcastle[04:46pm]~/test(1812) cat build.xml
<project name="test" default="xslttest" basedir=".">

<target name="xslttest">
<echo message="before test"/>
<xslt in="build.xml" out="results.txt" style="demo.xsl"/>
<echo message="after test"/>
</target>

</project>

***@dl-mcastle[04:46pm]~/test(1813) cat demo.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:number value="count(/project/target[echo])"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>

***@dl-mcastle[04:48pm]~/test(1821) cat results.txt
<?xml version="1.0" encoding="UTF-8"?>
1,
2.
Post by Will Lopez
Your'e stylesheet declaration is incorrect...see below...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "test">
..
Huh? That very well IS correct!

***@dl-mcastle[04:51pm]~/test(1825) cat demo.xsl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "[echo]">
]>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:number value="count(/project/target&foo;)"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>
***@dl-mcastle[04:51pm]~/test(1826) cat results.txt
<?xml version="1.0" encoding="UTF-8"?>
1,
2.
Post by Will Lopez
..to this **NOT TESTED** -it's been a while since I used XSLT but
there are tons of resources on the web...
http://www.w3schools.com/xsl/default.asp
http://www.w3.org/TR/xslt - W3C spec
http://www.zvon.org/HTMLonly/XSLTutorial/Books/Book1/index.html - check
this site out
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!ENTITY foo "test">
that is broken XML, however:

***@dl-mcastle[04:52pm]~/test(1828) cat demo.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!ENTITY foo "[echo]">
<xsl:template match="/">
<xsl:number value="count(/project/target&foo;)"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>

***@dl-mcastle[05:32pm]~/test(1829) ant
Buildfile: build.xml

xslttest:
[echo] before test
[xslt] Processing /homedir/mcastle/test/build.xml to /homedir/mcastle/test/results.txt
[xslt] Loading stylesheet /homedir/mcastle/test/demo.xsl
[xslt] [Fatal Error] demo.xsl:3:3: The content of elements must consist of well-formed character data or markup.
[xslt] : Fatal Error! org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
[xslt] Failed to process /homedir/mcastle/test/build.xml

BUILD FAILED
file:/homedir/mcastle/test/build.xml:5: Fatal error during transformation

mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
Will Lopez
2003-12-10 19:44:27 UTC
Permalink
Mike:

...one more thing...I wouldn't recommend using the RTF route unless you
had some transforming to do with those nodes held in the variable...if
so it would save you (the processor :-) from having to traverse the tree
again. Those types of XSLT questions are better suited on the
mulberrytech list where the gurus can advise you...I'm no guru :-)

Later
Post by Mike Castle
Unfortunately, when I checked the archives (prior to posting here), I was
unable to find anything directly addressing my real issue (which is the
parser yelling at me for no reason).
Post by Will Lopez
I don't understand what you're trying to accomplish...can you supply the
result you expect (and the input)...real code...this example only has a
template to match the root node and it will depend on the built in
templates to process the remaining nodes...also, you may just need a
variable.
Ok. Here.
<project name="test" default="xslttest" basedir=".">
<target name="xslttest">
<echo message="before test"/>
<xslt in="build.xml" out="results.txt" style="demo.xsl"/>
<echo message="after test"/>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:number value="count(/project/target[echo])"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
1,
2.
Post by Will Lopez
Your'e stylesheet declaration is incorrect...see below...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "test">
..
Huh? That very well IS correct!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY foo "[echo]">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:number value="count(/project/target&foo;)"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
1,
2.
Post by Will Lopez
..to this **NOT TESTED** -it's been a while since I used XSLT but
there are tons of resources on the web...
http://www.w3schools.com/xsl/default.asp
http://www.w3.org/TR/xslt - W3C spec
http://www.zvon.org/HTMLonly/XSLTutorial/Books/Book1/index.html - check
this site out
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!ENTITY foo "test">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!ENTITY foo "[echo]">
<xsl:template match="/">
<xsl:number value="count(/project/target&foo;)"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>
Buildfile: build.xml
[echo] before test
[xslt] Processing /homedir/mcastle/test/build.xml to /homedir/mcastle/test/results.txt
[xslt] Loading stylesheet /homedir/mcastle/test/demo.xsl
[xslt] [Fatal Error] demo.xsl:3:3: The content of elements must consist of well-formed character data or markup.
[xslt] : Fatal Error! org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
[xslt] Failed to process /homedir/mcastle/test/build.xml
BUILD FAILED
file:/homedir/mcastle/test/build.xml:5: Fatal error during transformation
mrc
Mike Castle
2003-12-09 23:41:37 UTC
Permalink
I see this thread is populated with responses. Thanks!
Post by Antoine Lévy-Lambert
Did you try the <xsl:import/> element instead of entities ?
I'm not using a SYSTEM entity to bring in a new file, however.

I just want to avoid having to type in a long string of characters over and
over.

Ok, actually, I'm more concerned about correctly updating the long strings
of characters when I make a change.

Basically I'm using the ENTITY as a macro.
Whoops! When I updated my news-to-email gateway, I forgot to delete the
old address. Corrected now, thanks.

mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
J.Pietschmann
2003-12-08 21:12:07 UTC
Permalink
Post by Mike Castle
So, is there anyway I can get ant to convince XSLT not to validate the
stylesheet, even though it has a DOCTYPE (I really don't want to have to
write a DTD for this thing)?
The noise comes from the parser, not from the XSLT processor. Actually
it's not really validating, otherwise you'd get a fatal error abort.
Post by Mike Castle
Or would anyone know how to hammer xsl:variables into doing what I want?
I'm not quite sure what you want to achieve. It seems you are after
a sort of dynamic XPath (usual question: are you sure you know what
you are doing?). This would require an extension function:
<xsl:variable name="foo">[test]</xsl:variable>
<xsl:variable name="bar" select="
xalan:evaluate(concat'/project/target',$foo))"/>
<xsl:value-of select="$bar"/>
In many cases there are simpler ways to do this. Please post a
description of your *original* problem on the XSL lits (see below).
Post by Mike Castle
Outside of that, where do I go to ask for help (specifically, what would
YOU recommend)? My searches really haven't turned up too much useful
information, but I'm new enough to this that I am probably missing useful
terms that would help.
The XSL list is good for all about XSL (both XSLT and XSLFO)
http://www.mulberrytech.com/xsl/xsl-list/

For questions about how Xalan handles certain stuff, in particular
extensions, check the Xalan docs and the Xalan user list.
For the concrete problem at hand it's Xerces who is responsible.
There are probably some options to shut it up. On how to apply
this options... you are back to ant.

J.Pietschmann
Mike Castle
2003-12-10 01:48:04 UTC
Permalink
Post by J.Pietschmann
Post by Mike Castle
So, is there anyway I can get ant to convince XSLT not to validate the
stylesheet, even though it has a DOCTYPE (I really don't want to have to
write a DTD for this thing)?
The noise comes from the parser, not from the XSLT processor. Actually
it's not really validating, otherwise you'd get a fatal error abort.
Ok. So I need to delve into why it's giving me that noise. Like I said,
it IS functioning correctly, but all of that noise is distracting and I'm
afraid that it will hide real errors down the line.
Post by J.Pietschmann
Post by Mike Castle
Or would anyone know how to hammer xsl:variables into doing what I want?
I'm not quite sure what you want to achieve. It seems you are after
a sort of dynamic XPath (usual question: are you sure you know what
Not really dynamic paths. I just want to avoid typing the same 80+
character predicate in multiple times and risk screwing it up.

I was looking at variables for the simple reason that using ENTITY was
causing me grief. I was merely looking at alternatives, not necessarily
wanting to use that method.
Post by J.Pietschmann
The XSL list is good for all about XSL (both XSLT and XSLFO)
http://www.mulberrytech.com/xsl/xsl-list/
Heh. Seems to be the popular one. :->
Post by J.Pietschmann
For questions about how Xalan handles certain stuff, in particular
extensions, check the Xalan docs and the Xalan user list.
For the concrete problem at hand it's Xerces who is responsible.
There are probably some options to shut it up. On how to apply
this options... you are back to ant.
Right. This is probably the most useful bit in the whole thread. At least
now I know what is responsible and can go poking around to figure out
what's going on.

Thanks,
mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
Stan Devitt
2003-12-10 05:10:36 UTC
Permalink
Mike,

By your comment about 80 character paths,
I kind of assume you have ruled out something
simple like the following which at least gives
you parameterized counting of the sort you
seem to be testing.

<target name="xslttest">
<echo message="before test"/>
<xslt in="build.xml" out="results.txt" style="newdemo.xsl">
<param name="type" expression="echo"/>
</xslt>
<echo message="after test"/>
</target>

where newdemo.xsl is given by:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="type" select="'DEFAULT_VALUE'"/>
<xsl:template match="/">
<xsl:number value="count(/project/target/*[local-name()=$type])"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>

Stan Devitt
...
Post by Mike Castle
Or would anyone know how to hammer xsl:variables into doing what I want?
Mike Castle
2003-12-10 22:26:33 UTC
Permalink
Post by Stan Devitt
By your comment about 80 character paths,
I kind of assume you have ruled out something
simple like the following which at least gives
you parameterized counting of the sort you
seem to be testing.
I think I have ruled it out. But I certainly would not be surprised that I
was wrong for doing so.
Post by Stan Devitt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="type" select="'DEFAULT_VALUE'"/>
<xsl:template match="/">
<xsl:number value="count(/project/target/*[local-name()=$type])"/>,
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>
Ok, that looks good for something like ``[test]]'' but what I really need
is a predicate that looks like:

LogRecord[@severity='MFATAL' or @severity='FATAL' or contains(text(),'Exception')]

And I'm not using it just as the level of a simple count() either, but
actually need that whole string of characters in mulitple places. Hence,
my use of entities.

mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
didge
2003-12-11 07:45:38 UTC
Permalink
Mike,

Since what you are asking for sounds like simple macro expansion, can you
preprocess the stylesheet with a tool like VPP (vpp.sourceforge.net) or even
use simple token replacement? You won't be using entity includes, so it
will get you around the problem, though it adds an additional processing
step.

didge
-----Original Message-----
Sent: Wednesday, December 10, 2003 2:27 PM
Subject: Re: XSLT with entities and therefore DOCTYPE
Post by Stan Devitt
By your comment about 80 character paths,
I kind of assume you have ruled out something
simple like the following which at least gives
you parameterized counting of the sort you
seem to be testing.
I think I have ruled it out. But I certainly would not be
surprised that I
was wrong for doing so.
Post by Stan Devitt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="type" select="'DEFAULT_VALUE'"/>
<xsl:template match="/">
<xsl:number
value="count(/project/target/*[local-name()=$type])"/>,
Post by Stan Devitt
<xsl:number value="count(/project/target/echo)"/>.
</xsl:template>
</xsl:stylesheet>
Ok, that looks good for something like ``[test]]'' but what I really need
contains(text(),'Exception')]
And I'm not using it just as the level of a simple count() either, but
actually need that whole string of characters in mulitple places. Hence,
my use of entities.
mrc
--
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all
different"); -- gcc
---------------------------------------------------------------------
Mike Castle
2003-12-11 19:04:56 UTC
Permalink
Post by didge
Since what you are asking for sounds like simple macro expansion, can you
preprocess the stylesheet with a tool like VPP (vpp.sourceforge.net) or even
use simple token replacement? You won't be using entity includes, so it
will get you around the problem, though it adds an additional processing
step.
Doh! Why didn't I think of that!

Thanks! Token replacement it is.

Though I'm still annoyed at xerces for yelling at me for no reason. :->

mrc
--
Mike Castle ***@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
Loading...