Jump to content

Trouble With Namspaces In Xslt

Recommended Posts

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>


<!--<!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 post
Share on other sites

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


on your xsl: stylesheet element does not make sense, you can drop that line.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...