namespaces and <xsl:value-of>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rainer Herbst

    namespaces and <xsl:value-of>

    Hi *,

    please help me solving the following problem:

    I have an XML document containing elements like
    <dir:director y xmlns:dir="http ://apache.org/cocoon/directory/2.0"
    name="pressemit teilungen" lastModified="1 064833858000" date="29.09.03
    13:10" size="4096" sort="name" reverse="false" requested="true ">
    <dir:file name="first.xml " lastModified="1 064833858000" date="29.09.03
    13:10" size="62"/>
    </dir:directory>

    How should I refer to these elements in
    <xsl:value-of/> ?

    <xsl:value-of select="//dir:file"/>
    gives me an error, so what can I do?

    TIA!
    Rainer


    --
    ------------------------------------------------
    Rainer Herbst Linux - Registered
    ZEIK User #319157
    Universität Potsdam Usual disclaimers applies!
    ------------------------------------------------

  • Richard Tobin

    #2
    Re: namespaces and &lt;xsl:valu e-of&gt;

    In article <bl9dhg$cag$1@z eppelin.rz.uni-potsdam.de>,
    Rainer Herbst <rherbst_@_rz.u ni-potsdam.de> wrote:[color=blue]
    ><xsl:value-of select="//dir:file"/>
    >gives me an error, so what can I do?[/color]

    Do you have a declaration for the dir prefix in the stylesheet? E.g.
    on the top level element:

    <xsl:styleshe et xmlns:dir="http ://apache.org/cocoon/directory/2.0" ...>
    ...

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

    FreeBSD rules!

    Comment

    • Jesper Zedlitz

      #3
      Re: namespaces and &lt;xsl:valu e-of&gt;

      > <xsl:value-of select="//dir:file"/>[color=blue]
      > gives me an error, so what can I do?
      >[/color]
      Do you have declared the prefix "dir" for that position of the XSL document?

      You can define it for the whole stylsheet by writing
      <xsl:styleshe et version="1.0"
      xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
      xmlns:dir="http ://apache.org/cocoon/directory/2.0" >

      Jesper

      --
      Jesper Zedlitz eMail : jesper@zedlitz. de
      Homepage : http://www.zedlitz.de
      ICQ# : 23890711
      PGP-Key : http://zedlitz.de/pub_key.asc

      Comment

      • Francesc Guim Bernat

        #4
        Re: namespaces and &lt;xsl:valu e-of&gt;



        Rainer Herbst wrote:[color=blue]
        > Hi *,
        >
        > please help me solving the following problem:
        >
        > I have an XML document containing elements like
        > <dir:director y xmlns:dir="http ://apache.org/cocoon/directory/2.0"
        > name="pressemit teilungen" lastModified="1 064833858000" date="29.09.03
        > 13:10" size="4096" sort="name" reverse="false" requested="true ">
        > <dir:file name="first.xml " lastModified="1 064833858000" date="29.09.03
        > 13:10" size="62"/>
        > </dir:directory>
        >
        > How should I refer to these elements in
        > <xsl:value-of/> ?
        >
        > <xsl:value-of select="//dir:file"/>
        > gives me an error, so what can I do?[/color]

        I supose that you've not declaret the namespace "dir" in your stylesheet
        node of your XSTL. You must declare it, for instance:

        <?xml version="1.0" encoding="UTF-8"?>
        <xsl:styleshe et version="1.0"
        xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
        xmlns:dir="http ://apache.org/cocoon/directory/2.0"[color=blue]
        >[/color]
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:value-of select="//dir:file"/>

        <!-- Your xstl code -->
        </xsl:stylesheet>


        Francesc Guim
        [color=blue]
        >
        > TIA!
        > Rainer
        >
        >[/color]

        Comment

        Working...