Re: [xslt] Namespace problem



Might help if I actually attached the files :)

--Brent

On Mon, Apr 02, 2001 at 03:44:27PM -0500, Brent Hendricks wrote:
> I'm having trouble getting xsl:value-of to work with namespaces.  I
> have the following XML document.  I've declared a namespace prefix
> 'my:' byt I can't get seem to select any elements from this namespace?  
> 
> I've attached a simple XML file with a <document> tag and a <name>
> tag, along with a stylesheet that attempts to transform this into
> XHTML, putting the value of <name> into the XHTML <title> and into a
> <h1> heading.  When I run the transformation using xsltproc I just get
> empty <title> and <h1> tags.
> 
> Has anyone else seen this problem?  Is it a known bug in libxslt?
> 
> Thanks,
> Brent
> 
> -------------------------------------------------------------------------
> 
> "The programmer, like the poet, works only slightly removed from pure
>  thought-stuff.  He builds his castles in the air, from air, creating
>  by exertion of the imagination.  Few media of creation are so
>  flexible, so easy to polish and rework, so readily capable of
>  realizing grand conceptual structures."
>                         -- Frederick Brooks, Jr., The Mythical Man Month
> 
> _______________________________________________
> xslt mailing list
> xslt gnome org
> http://mail.gnome.org/mailman/listinfo/xslt

-------------------------------------------------------------------------

"The programmer, like the poet, works only slightly removed from pure
 thought-stuff.  He builds his castles in the air, from air, creating
 by exertion of the imagination.  Few media of creation are so
 flexible, so easy to polish and rework, so readily capable of
 realizing grand conceptual structures."
                        -- Frederick Brooks, Jr., The Mythical Man Month
<?xml version="1.0"?>

<document xmlns="http://my/namespace";>
  <name>Title of my document</name>
</document>

<?xml version= "1.0"?>

<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:my="http://my/namespace";
  xmlns="http://www.w3.org/1999/xhtml";>
  
  <!-- Root Node -->
  <xsl:template match="/">
    <html>
      <head>
        <title><xsl:value-of select="my:document/my:name"/></title>
      </head>	
      <xsl:apply-templates/>
    </html>
  </xsl:template>
  
  <!-- Header and Body for the Document -->
  <xsl:template match="my:document">
    <body>
      <h1><xsl:value-of select="my:name"/></h1>
      <xsl:apply-templates/>
      <hr/>
    </body>
  </xsl:template>
  
  <!--Don't display name-->
  <xsl:template match="my:name">
  </xsl:template>

</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]