← Prev in month
← Prev in thread
xml, xslt and namespaces
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
← Prev in month
← Prev in thread