ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dalg...@ix.netcom.com (Mike Castle)
Subject Re: AW: XSLT with entities and therefore DOCTYPE
Date Wed, 10 Dec 2003 00:33:53 GMT
In article <3FD4E8AD.4050200@koberg.com>,
Robert Koberg  <user@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


Mime
View raw message