Connecting Tech Pros Worldwide Help | Site Map

But it works without a namespace

  #1  
Old February 16th, 2007, 03:35 AM
nhogge@gmail.com
Guest
 
Posts: n/a
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

  #2  
Old February 16th, 2007, 01:25 PM
Martin Honnen
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
(WPF Web App) - How to properly scroll a TreeListView without head =?Utf-8?B?Um9iZXJ0Vw==?= answers 1 December 10th, 2007 10:05 PM
Is 'using namespace std;' valid without 'namespace std {};' first? Petter Reinholdtsen answers 8 July 22nd, 2005 11:21 PM
Hiding function works on IE, but it doesn't on Moziila atomo answers 3 July 20th, 2005 01:03 PM
Crimson says namespace attribute must preceed other attributes -- true? Scott Sauyet answers 6 July 20th, 2005 09:36 AM