Results 1 to 4 of 4

Thread: XSLT (XSL) and <xsl:value-of select="

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    XSLT (XSL) and <xsl:value-of select="

    In my XSLT I have:
    Code:
    <xsl:value-of select="Woof"/>
    This outputs whatever the value of Woof is in my Dataset.
    But lets say the "field" Woof cantains:
    Code:
    <IMG SRC="\Images\Fish.jpg"/>
    Then what happens is the XSLT sheet acutally formats this to display the text "<IMG SRC="\Images\Fish.jpg"/>", instead of rendering the code as HTML and displaying the picture.
    How do I stop the XSL sheet reformatting html code in field names?

    Woof

  2. #2
    Member
    Join Date
    Sep 2004
    Location
    Oklahoma City, OK
    Posts
    36
    The trouble here is that you're trying to pass a string value to the XSL processor to be rendered as HTML code, which the processor cannot do natively. There are a few solutions to this, however only a one or two are correct.

    If you must keep the format of the output HTML in the database field, then you will need to tell the processor to disable output escaping. This isn't recommended because it can cause either your output or stylesheet to break from lack of well-formedness.

    Code:
    <xsl:value-of select="Woof" disable-output-escaping="yes" />
    The better way to perform this would be to change the field to contain only the path for the image, in this case "\images\fish.jpg" and modify your XSL as:

    Code:
            <img src="{Woof}" />
    
             or
    
            <xsl:param name="ImgSrc" select="Woof" />
            <img src="{$Woof}" />
    T

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Cheers. Usefull code.
    What I have is:
    Hello my name is a fish.
    This is a demo post for the purpose of this thread MOOSE
    Sometimes, I type rubbish FISH, but not always.

    Rarrrrrr...Sausages...FISH
    OK, I have that in my DB.
    Now, I want to replace the words MOOSE and FISH with image tags...

    Woka

  4. #4
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    Originally posted by Wokawidget
    Cheers. Usefull code.
    What I have is:

    OK, I have that in my DB.
    Now, I want to replace the words MOOSE and FISH with image tags...

    Woka
    Store the path of your images that are sitting on your web server in the db. Then you can easily output them

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width