OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   xml, xslt and namespaces

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev <xml-dev@lists.xml.org>
  • Subject: xml, xslt and namespaces
  • From: Mahdi Mankai <manm08@uqo.ca>
  • Date: Thu, 16 Sep 2004 15:08:50 -0400
  • User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

Hi to all,
I wonder if somebody can afford me a suitable solution for my problem.
starting from from an original xml file that uses namespaces :

<?xml version="1.0" encoding="UTF-8"?>

<h:request xmlns:h="http://www.mydomain.org/ns/";>>
    <h:title>
        XML, XSLT and Namespaces
    </h:title>
   
    <h:message>
        How to reference XML source namespaces in XSLT files
    </h:message>
</h:request>

I want to transform it into xslt. the problem is that I dont know how to 
resolve the original xml namespaces. If I use the following xslt it 
doesn't work :

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns="http://www.w3.org/TR/xhtml1/strict";>

<xsl:output method="html"/>

<xsl:template match="/">
<html>
    <title> xml-dev request </title>
   
      <body>
      <b>
      Request
      </b>
      <br/>
      <b>
      <xsl:value-of select="request/h:title"/>
      </b>
      <br/>
      <xsl:value-of select="request/h:message"/>
     
       </body>
</html>
</xsl:template>
</xsl:stylesheet>

I found a solution for that by adding the xml namespaces like that :

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:h="http://www.mydomain.org/ns/";
                xmlns="http://www.w3.org/TR/xhtml1/strict";>

<xsl:output method="html"/>

<xsl:template match="/">
<html>
    <title> xml-dev request </title>
   
      <body>
      <b>
      Request
      </b>
      <br/>
      <b>
      <xsl:value-of select="h:request/h:title"/>
      </b>
      <br/>
      <xsl:value-of select="h:request/h:message"/>
     
       </body>
</html>
</xsl:template>
</xsl:stylesheet>

this solution doesn't suit me because I want to avoid rewriting the h: 
prefix with every tag!!!

I hope that somebody can help me.
Thanks.
Mahdi

-- 
Mahdi MANKAI
Master Student
Université du Québec en Outaouais
Local B-2003
Tel. (819) 595 3900 Ext. 1705






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS