Jump to content

XSLT for XML with Namspaces (xmlns)


Guest Shivek

Recommended Posts

Guest Shivek

i'm having problem regarding transformation of XML document which is part of a namespace.i have an xml document in which the element is part of a namespacee.g.<name xmlns="http://www.example.org"> <firstname>John</firstname> <lastname>Doe</lastname></name>i've tried using XSLT to transform this document but none of the values are being displayed,i've tried reading the XSLT tutorial about including namespaces in:<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">but i'm still not sure what i have to do so that the values would appear after applying the XSLT.cheers,Shivek

Link to comment
Share on other sites

You might want to show the full XSLT you have. It would have been easier to put it out as an example.Now... your huntch about applying it on xsl:stylesheet is correct. You need to designate a prefix (any prefix) and apply the namespace URI from the source document on it. Later, when you need to target an element in that namespace, use the prefix in the XPath expression. For example:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:e="http://www.example.org"><xsl:template match="/"><xsl:value-of select="e:name"/></xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...