You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mike Castle <da...@ix.netcom.com> on 2003/12/08 21:23:16 UTC

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      dalgoda@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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: XSLT with entities and therefore DOCTYPE

Posted by Mike Castle <da...@ix.netcom.com>.
In article <PL...@foundrylogic.com>,
didge <di...@foundrylogic.com> wrote:
>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      dalgoda@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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: XSLT with entities and therefore DOCTYPE

Posted by didge <di...@foundrylogic.com>.
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-----
> From: Mike Castle [mailto:dalgoda@ix.netcom.com]
> Sent: Wednesday, December 10, 2003 2:27 PM
> To: user@ant.apache.org
> Subject: Re: XSLT with entities and therefore DOCTYPE
>
>
> In article <3F...@stratumtek.com>,
> Stan Devitt  <us...@ant.apache.org> wrote:
> >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.
>
> ><?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      dalgoda@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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: XSLT with entities and therefore DOCTYPE

Posted by Mike Castle <da...@ix.netcom.com>.
In article <3F...@stratumtek.com>,
Stan Devitt  <us...@ant.apache.org> wrote:
>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.

><?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      dalgoda@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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: XSLT with entities and therefore DOCTYPE

Posted by Stan Devitt <js...@stratumtek.com>.
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

Mike Castle wrote:

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



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: XSLT with entities and therefore DOCTYPE

Posted by Mike Castle <da...@ix.netcom.com>.
In article <3F...@yahoo.de>,
J.Pietschmann <us...@ant.apache.org> wrote:
>Mike Castle wrote:
>> 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.

>> 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:

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.

>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.  :->

>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      dalgoda@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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: XSLT with entities and therefore DOCTYPE

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Mike Castle wrote:
> 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.

> 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).

> 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



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: XSLT with entities and therefore DOCTYPE

Posted by Mike Castle <da...@ix.netcom.com>.
I see this thread is populated with responses.  Thanks!

In article <NC...@antbuild.com>,
Antoine L�vy-Lambert  <us...@ant.apache.org> wrote:
>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.

>BTW : the address of this mailing list is user@ant.apache.org

Whoops!  When I updated my news-to-email gateway, I forgot to delete the
old address.  Corrected now, thanks.

mrc


-- 
     Mike Castle      dalgoda@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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: XSLT with entities and therefore DOCTYPE

Posted by Will Lopez <wi...@eds.com>.
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

Mike Castle wrote:

>In article <3F...@eds.com>, Will Lopez  <us...@ant.apache.org> wrote:
>  
>
>>A very good XSL list is xsl-list@lists.mulberrytech.com.
>>    
>>
>
>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).
>
>  
>
>>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.
>
>mcastle@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>
>
>mcastle@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>
>
>mcastle@dl-mcastle[04:48pm]~/test(1821) cat results.txt 
><?xml version="1.0" encoding="UTF-8"?>
>1,
>    2.
>
>
>
>  
>
>>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">
>>..
>>    
>>
>
>Huh?  That very well IS correct!
>
>mcastle@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>
>mcastle@dl-mcastle[04:51pm]~/test(1826) cat results.txt 
><?xml version="1.0" encoding="UTF-8"?>
>1,
>    2.
>
>
>  
>
>>..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:
>
>mcastle@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>
>
>mcastle@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
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: XSLT with entities and therefore DOCTYPE

Posted by Mike Castle <da...@ix.netcom.com>.
In article <3F...@eds.com>, Will Lopez  <us...@ant.apache.org> wrote:
>A very good XSL list is xsl-list@lists.mulberrytech.com.

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).

>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.

mcastle@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>

mcastle@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>

mcastle@dl-mcastle[04:48pm]~/test(1821) cat results.txt 
<?xml version="1.0" encoding="UTF-8"?>
1,
    2.



>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">
>..

Huh?  That very well IS correct!

mcastle@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>
mcastle@dl-mcastle[04:51pm]~/test(1826) cat results.txt 
<?xml version="1.0" encoding="UTF-8"?>
1,
    2.


>..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:

mcastle@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>

mcastle@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      dalgoda@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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: XSLT with entities and therefore DOCTYPE

Posted by Will Lopez <wi...@eds.com>.
A very good XSL list is xsl-list@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


Antoine Lévy-Lambert wrote:

>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 user@ant.apache.org
>Cheers,
>Antoine
>
>-----Ursprüngliche Nachricht-----
>Von: Mike Castle [mailto:dalgoda@ix.netcom.com]
>Gesendet: Montag, 8. Dezember 2003 21:23
>An: ant-user@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      dalgoda@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
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: XSLT with entities and therefore DOCTYPE

Posted by Mike Castle <da...@ix.netcom.com>.
In article <3F...@koberg.com>,
Robert Koberg  <us...@ant.apache.org> wrote:
>> -----Urspr�ngliche Nachricht-----
>> Von: Mike Castle [mailto:dalgoda@ix.netcom.com]
>> 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).

>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.  :-/

>> 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"/>
>
>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.

>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)"/>

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.

>> 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?

>> 
>> 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      dalgoda@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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: XSLT with entities and therefore DOCTYPE

Posted by Robert Koberg <ro...@koberg.com>.
> -----Ursprüngliche Nachricht-----
> Von: Mike Castle [mailto:dalgoda@ix.netcom.com]
> Gesendet: Montag, 8. Dezember 2003 21:23
> An: ant-user@jakarta.apache.org
> 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).

> 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"/>

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"
   select="/project/target/*[local-name()=$foo]/@something"/>





>     <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.
> 
> Or would anyone know how to hammer xsl:variables into doing what I want?

don't know what you 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.

see above

best,
-Rob

> 
> Thanks a lot,
> mrc
> --
>      Mike Castle      dalgoda@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




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: XSLT with entities and therefore DOCTYPE

Posted by Antoine Lévy-Lambert <an...@antbuild.com>.
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 user@ant.apache.org
Cheers,
Antoine

-----Ursprüngliche Nachricht-----
Von: Mike Castle [mailto:dalgoda@ix.netcom.com]
Gesendet: Montag, 8. Dezember 2003 21:23
An: ant-user@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      dalgoda@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



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org