Mike Castle
2003-12-08 20:23:16 UTC
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
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
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