[XSLT] Is this a bug ( in the spec / in the tool ) ?

Discussion in 'XML' started by Philippe Poulard, Dec 3, 2003.

  1. Hi,

    I need to define inside my stylesheet some xml structured datas, like
    this (this example works) :

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0"
    xmlns:data="*** Datas ***"
    exclude-result-prefixes="data">

    <data:foo bar="data"/>

    <xsl:template match="/">
    <!-- XSLT stuff here -->
    <xsl:template>

    </xsl:stylesheet>

    unfortunately, the content of my data structure contains values with
    brackets and dollars, like this :

    <data:foo bar="{$data}"/>

    when i create the template, i catch the following exception :
    javax.xml.transform.TransformerException:
    org.apache.xml.utils.WrappedRuntimeException: Could not find variable
    with the name of data

    because the xslt unmarshaler think that it is an attribute value
    template; however, it is not, because present outside any context
    handable by some xslt features such as output production or variable
    computation; it is only valid xml data, and i want to retrieve this data
    as it is written !

    it is not clear in the spec that such a particular case should not be
    evaluate as an AVT (if anybody knows, tell me)
    i don't think it have to, because this part of the document is not for
    the xslt processor, and can't be handled by it (i think); escaping with
    {{ and }} has sense only for real AVT and would corrupt my datas, so it
    is not acceptable

    the only way to avoid this is to declare a variable of that name in the
    scope of the data, like this :

    <xsl:variable name="data"/>
    <data:foo bar="{$data}"/>

    baaah ! i don't want to declare false variables for my thousand datas :(
    i really think it's a bug

    do you think there is a lack in the spec ?
    do you think this is a bug in apache ?
    --
    Cordialement,

    ///
    (. .)
    -----ooO--(_)--Ooo-----
    | Philippe Poulard |
    -----------------------
    Philippe Poulard, Dec 3, 2003
    #1
    1. Advertising

  2. In article <bql9na$43r$>,
    Philippe Poulard <> wrote:

    ><data:foo bar="{$data}"/>


    The processor is right to interpret this as an attribute value
    template; indeed the spec gives it as an example: "such as an
    attribute of a literal result element". It's just the sort of thing
    that attribute value templates are meant for.

    You could write it as <data:foo bar="{'{$data}'}"/>

    -- Richard
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
    Richard Tobin, Dec 3, 2003
    #2
    1. Advertising

  3. Richard Tobin wrote:
    > In article <bql9na$43r$>,
    > Philippe Poulard <> wrote:
    >
    >
    >><data:foo bar="{$data}"/>

    >
    >
    > The processor is right to interpret this as an attribute value
    > template; indeed the spec gives it as an example: "such as an
    > attribute of a literal result element". It's just the sort of thing
    > that attribute value templates are meant for.
    >
    > You could write it as <data:foo bar="{'{$data}'}"/>
    >
    > -- Richard


    the example i described before is erroneous (in fact, there is a little
    difference with the real case i encountered); i read again the spec and
    made some other tests;

    in fact, the problem i described cause no error because it is said that
    "not all attributes are interpreted as attribute value
    templates.../...attributes of top-level elements (.../...) are not
    interpreted as attribute value templates"

    so, the example above works perfectly because <data:foo bar="{$data}"/>
    is one of the top level elements

    the processor is strictly conformant to the spec, because the following
    case :
    <xsl:stylesheet ...>
    <data:foos>
    <data:foo bar="{$data}"/>
    </data:foos>
    ...
    </xsl:stylesheet>
    causes an error, and that's my really problem

    however, i really think it shouldn't be interpreted as avt, because the
    purpose of the avt is to perform computation on literal result element;
    in my case, it is not literal result element because this xml structure
    is out of the scope of the processor : "an XSLT processor (.../...) must
    ignore a top-level element without giving an error if it does not
    recognize the namespace URI"; it is obvious that subelements should also
    be ignored because the processor can't handle the result in any way, and
    if i use the document('') function, i need to retrive the value {$data},
    not the value {'{$data}'}
    --
    Cordialement,

    ///
    (. .)
    -----ooO--(_)--Ooo-----
    | Philippe Poulard |
    -----------------------
    Philippe Poulard, Dec 4, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Philips
    Replies:
    3
    Views:
    364
    John Keyes
    Sep 23, 2004
  2. Victor Porton
    Replies:
    0
    Views:
    396
    Victor Porton
    Jun 1, 2004
  3. Ken Philips
    Replies:
    1
    Views:
    346
    Tjerk Wolterink
    Sep 22, 2004
  4. Gilgamesh

    XSLT from a XSD spec.

    Gilgamesh, Oct 4, 2006, in forum: XML
    Replies:
    5
    Views:
    571
    Manuel Collado
    Oct 5, 2006
  5. Andrew Chen
    Replies:
    1
    Views:
    190
    David Chelimsky
    Mar 25, 2008
Loading...

Share This Page