Loading ...
Sorry, an error occurred while loading the content.

Tag problems

Expand Messages
  • evans_marc@jpmorgan.com
    Hi All, I hope that this is the correct group for this kind of question. I m having problems using the tag in XSL. The code below is the kind of
    Message 1 of 2 , May 13, 2001
    • 0 Attachment
      Hi All,

      I hope that this is the correct group for this kind of question. I'm
      having problems using the <attribute> tag in XSL. The code below is
      the kind of thing that I'm trying to use, however with no luck.

      <?xml version="1.0"?>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      ----other stuff------
      <IMG>
      <xsl:attribute name="src">
      <xsl:value-of select="Column[0]/ColumnScaleValue"/>
      </xsl:attribute>
      </IMG>
      ----other stuff------
      </xsl:stylesheet>

      Am I using the correct name space? I'm using IE5.50 if this helps.

      Thanks for any help,
      Marc
    • John E. Simpson
      ... Yes, that s the correct namespace declaration. (However, you seem to be transforming to (X)HTML rather than to XSL-FO. If that s the case, the message
      Message 2 of 2 , May 13, 2001
      • 0 Attachment
        At 01:59 PM 05/13/2001 +0000, evans_marc@... wrote:
        ><?xml version="1.0"?>
        ><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        >----other stuff------
        ><IMG>
        ><xsl:attribute name="src">
        ><xsl:value-of select="Column[0]/ColumnScaleValue"/>
        ></xsl:attribute>
        ></IMG>
        >----other stuff------
        ></xsl:stylesheet>
        >
        >Am I using the correct name space? I'm using IE5.50 if this helps.

        Yes, that's the correct namespace declaration. (However, you seem to be
        transforming to (X)HTML rather than to XSL-FO. If that's the case, the
        message should probably have gone to either XSL-List or XHTML-L. Be that as
        it may....)

        There are two possible problems with the XSLT fragment you posted. In
        descending order of likelihood (I think):

        (1) The select attribute to that xsl:value-of element says (in English) to
        transfer to the result tree the ColumnScaleValue child of a Column child of
        the context node, as long as that Column child is in position #0 among
        *all* Column children of the context node. I'm having a difficult time
        imagining the 0th child of a context node, and I'll bet IE5.5 is, too.
        :) Positions (such as used in the [0] predicate in your example) are not
        0-based; they start with 1 and go up to the value returned by the last()
        function at that point. You probably want [1] instead.

        (2) IE5.5 has in the past had problems with newlines embedded in attribute
        values. In your sample code, the content of the xsl:attribute element
        consists of a newline (immediately following the start tag), followed by
        the value of the xsl:value-of element, followed by a newline (preceding the
        end tag). Try getting rid of the newlines.

        Assuming that my assumption in (1) is correct -- that you want the first
        child, not the 0th (which doesn't exist) -- then I think you've got a
        couple choices.

        First, you can turn the xsl:attribute element into an *empty* element with
        a select attribute of its own. Thus:

        <xsl:attribute name="src"
        select="Column[1]/ColumnScaleValue"/>

        Or you can avoid using xsl:attribute altogether, using instead an attribute
        value template (AVT) in the <IMG...> start tag. Thus:

        <IMG src="{Column[1]/ColumnScaleValue}" />

        Note that those are curly braces within the value of the src attribute;
        they're what makes it an AVT. You can use an AVT in the value of any
        result-tree attribute, which obviates the need to use the xsl:attribute
        element in such cases (except where you must compute the the attribute's
        *name*).

        ================================================================
        John E. Simpson | "I can levitate birds. No one cares."
        http://www.flixml.org | (Steven Wright)
        XML Q&A: www.xml.com |
      Your message has been successfully submitted and would be delivered to recipients shortly.