Connecting Tech Pros Worldwide Help | Site Map

But it works without a namespace

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 16th, 2007, 02:35 AM
nhogge@gmail.com
Guest
 
Posts: n/a
Default But it works without a namespace

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, 12:25 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.