XML and XSLT with Namespaces

Soldato
Joined
18 Oct 2002
Posts
4,925
Location
Yorkshire
I've got an XML with something like the following structure

Code:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="CarePlanRetrieve.xslt"?>
<TestRoot xmlns="http://www.justatestnamespace.com/" >
<data clientnnn="1234567890" datasettype="CAR">
          <problem id="19546">
            <entrydate>2006-09-12T14:03:48</entrydate>
            <updatedate>2007-10-23T10:18:30</updatedate>
          </problem>
  </data>
</TestRoot>

Notice that its got a name space (xmlns="http://www.justatestnamespace.com/")

Now my XSLT looks something like this
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:booga="http://www.justatestnamespace.com/">

		<xsl:output method="html"/>

		<xsl:template match="/">
			<xsl:for-each select="booga:TestRoot/booga:problem">
				Test: <xsl:value-of select="booga:entrydate" />
			</xsl:for-each>
		</xsl:template>		
	
</xsl:stylesheet>

As you can see in the xslt i've included the namespace as (xmlns:booga="http://www.justatestnamespace.com/"). My problem is that whenever type an xml element with in the for loop and value-of I have to preceed it with (booga:).

Is this normal or is there a better way to do this ?
 
Back
Top Bottom