Grasslands Posted October 21, 2011 Share Posted October 21, 2011 Hi. I have some XML which I am trying to transform. The XML has namespaces,and I cannot seem to find the nodes while transforming with my xslt. XML sample <?xml version="1.0" encoding="UTF-8"?><Message xsi:schemaLocation="http://www.theia.org.uk/ILR/2011-12/1 ILR-2011-12-Structure.xsd" xmlns="http://www.theia.org.uk/ILR/2011-12/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header> <CollectionDetails> <Collection>ILR</Collection> <Year>1112</Year> <FilePreparationDate>2011-10-21</FilePreparationDate> </CollectionDetails> </Header></Message> XSL <!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> --><?xmls version "1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:t="http://www.theia.org.uk/ILR/2011-12/1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/2001/XMLSchema-instance" xmlns:xslFormatting="urn:xslFormatting"> <xsl:output method="html" indent="no"/> <xsl:template match="/t:Message"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <h2> <xsl:value-of select="t:Header/CollectionDetails/Collection"/> </h2> </body> </html> </xsl:template></xsl:stylesheet> Please help Many thanks Link to comment Share on other sites More sharing options...
Martin Honnen Posted October 21, 2011 Share Posted October 21, 2011 You need to consistently apply that prefix "t" i.e. <xsl:value-of select="t:Header/t:CollectionDetails/t:Collection"/> as the xmlns="..." on the root element in the input element applies to that element and all its descendant elements. Also xmlns="http://www.w3.org/2001/XMLSchema-instance" on your xsl: stylesheet element does not make sense, you can drop that line. Link to comment Share on other sites More sharing options...
Grasslands Posted October 21, 2011 Author Share Posted October 21, 2011 Many thanks for such a speedy reply that works. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.