Connecting Tech Pros Worldwide Help | Site Map

But it works without a namespace

nhogge@gmail.com
Guest
 
Posts: n/a
#1: Feb 16 '07
I have recently come to peace with XML namespaces and have switch to
always ripping them out to using them. Has not been too bad but some
things I use to do no longer work.

Given this XML:

<?xml version="1.0"?>
<UpdateManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/
updatemanifest">
<UpdateFiles>
<UpdateFile>
<Id>dbc5f337-176e-486f-95f9-83a997256417</Id>
<UpdateFileName>generic3.exe</UpdateFileName>
</UpdateFile>
</UpdateFiles>
<Updates>
<Update>
<Id>f428a425-82d5-484a-8a81-1b0bf7097b77</Id>
<FileId>d2aac5f1-559b-4b47-bddd-a2ed455d251a</FileId>
</Update>
</Updates>
</UpdateManifest>

And this XSL:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:m="http://tempuri.org/updatemanifest"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" encoding="iso-8859-1"
indent="no"/>
<xsl:template match="/">
<table class="TableListing" cellpadding="0" cellspacing="0"
border="2">
<xsl:for-each select="/m:UpdateManifest/m:Updates/m:Update">
<tr>
<td>
<xsl:variable name="curfileid" select="m:FileId"/>
<xsl:value-of select="/m:UpdateManifest/m:UpdateFiles/
m:UpdateFile[m:Id = $curfileid]/m:UpdateFileName"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

The select "/m:UpdateManifest/m:UpdateFiles/m:UpdateFile[m:Id =
$curfileid]/m:UpdateFileName" does not return anything.

If I remove xmlns="http://tempuri.org/updatemanifest" from the xml and
all the "m:" namespace stuff from the XSL, it works as expected
(returns 'generic3.exe'). I am using XslCompiledTransform.

Any ideas what is up here. If not I guess I will go back to being a
namespace stripper.

Nathan

Martin Honnen
Guest
 
Posts: n/a
#2: Feb 16 '07

re: But it works without a namespace


nhogge@gmail.com wrote:
Quote:
<UpdateManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/
updatemanifest">
<UpdateFiles>
<UpdateFile>
<Id>dbc5f337-176e-486f-95f9-83a997256417</Id>
<UpdateFileName>generic3.exe</UpdateFileName>
</UpdateFile>
</UpdateFiles>
<Updates>
<Update>
<Id>f428a425-82d5-484a-8a81-1b0bf7097b77</Id>
<FileId>d2aac5f1-559b-4b47-bddd-a2ed455d251a</FileId>
</Update>
</Updates>
</UpdateManifest>
>
And this XSL:
>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:m="http://tempuri.org/updatemanifest"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" encoding="iso-8859-1"
indent="no"/>
<xsl:template match="/">
<table class="TableListing" cellpadding="0" cellspacing="0"
border="2">
<xsl:for-each select="/m:UpdateManifest/m:Updates/m:Update">
<tr>
<td>
<xsl:variable name="curfileid" select="m:FileId"/>
So for the above XML sample the variable is
"d2aac5f1-559b-4b47-bddd-a2ed455d251a"
then you compare to
Quote:
<xsl:value-of select="/m:UpdateManifest/m:UpdateFiles/
m:UpdateFile[m:Id = $curfileid]/m:UpdateFileName"/>
"dbc5f337-176e-486f-95f9-83a997256417"
which is different.




--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Closed Thread