Subject: Re: [xsl] Empty node set when namespace nodes are used From: Hans Huber <hans.huber@xxxxxxxx> Date: Thu, 23 May 2002 19:39:31 +0200 |
Hi,
I am trying to translate an input source file which contains a namespace
declaration and have problems with node match conditions when namespace
nodes are involved (for example: <xsl:for-each select="TNMS:TNMSData/NEs/NE"> fails to produce a
nodeset.
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- TNMS Export Start-Time: Fri, 12 Apr 2002, 10:24:16 --> <!-- TNMS Server: 'V7-SERVER' --> <?xml:stylesheet type="text/xsl" href="C:\workspace\accessfiberimpl\corbainterface\interop\etc\stylesheets\tn msData2afiop.xsl" ?> <TNMSData xmlns="x-schema:C:\WINNT\TNMSDataSchema.xml"> <TNMSData> <!-- NEs --> <NEs> <!-- NE --> <NE IDName="WL8_1"> <NEType GUID="41286880-FC3C-11D4-B36C-000102B8B8D5"/> <ParentID EID="Dch: {NS1-QB3-Channel}"/> <PropContainer> <PropStore GUID="43047833-19CA-42DD-944C-DC1BDF786649"> <Property Name="AdminState" Type="VT_I4">4</Property> <Property Name="NeLocation" Type="VT_BSTR">GR02/Rack021/Subrack08/Einschub01(Oberg.)</Property> <Property Name="NeName" Type="VT_BSTR">WLT8#01</Property> <Property Name="NeType" Type="VT_BSTR">WLT 2.1-2.3</Property> </PropStore> </PropContainer> </NE> </NEs> </TNMSData>
In my stylesheet, I try to extract all <NE> elements from the source file and perform some transformations.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:TNMS="x-schema:C:\WINNT\TNMSRilSchema.xml">
<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8"
indent="yes"/>
<!-- omit the TNMS namespace in the accessFIBER XML files --> <xsl:namespace-alias stylesheet-prefix="TNMS" result-prefix="#default"/>
<xsl:template match="/"> <xsl:if test="TNMS:TNMSData/NEs"> <AFIOPNetworkData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <AFIOPCardcages> <xsl:for-each select="TNMS:TNMSData/NEs/NE"><xsl:call-template name="cardcageTemplate"/></xsl:for-each> </AFIOPCardcages> </AFIOPNetworkData> </xsl:if> </xsl:template>
============================================================================ ==============
Upon debugging, I comment out the TNMS namespace declaration in the input source file and remove all references to the TNMS namespace in my stylesheet, then I don't run into any problems with my match conditions.
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- TNMS Export Start-Time: Fri, 12 Apr 2002, 10:24:16 --> <!-- TNMS Server: 'V7-SERVER' --> <?xml:stylesheet type="text/xsl" href="C:\workspace\accessfiberimpl\corbainterface\interop\etc\stylesheets\tn msData2afiop.xsl" ?> <TNMSData> <!-- NEs --> <NEs> <!-- NE --> <NE IDName="WL8_1"> <NEType GUID="41286880-FC3C-11D4-B36C-000102B8B8D5"/> <ParentID EID="Dch: {NS1-QB3-Channel}"/> <PropContainer> <PropStore GUID="43047833-19CA-42DD-944C-DC1BDF786649"> <Property Name="AdminState" Type="VT_I4">4</Property> <Property Name="NeLocation" Type="VT_BSTR">GR02/Rack021/Subrack08/Einschub01(Oberg.)</Property> <Property Name="NeName" Type="VT_BSTR">WLT8#01</Property> <Property Name="NeType" Type="VT_BSTR">WLT 2.1-2.3</Property> </PropStore> </PropContainer> </NE> </NEs> </TNMSData>
Modified stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8"
indent="yes"/>
<xsl:template match="/"> <xsl:if test="TNMSData/NEs"> <AFIOPNetworkData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <AFIOPCardcages> <xsl:for-each select="TNMSData/NEs/NE"><xsl:call-template name="cardcageTemplate"/></xsl:for-each> </AFIOPCardcages> </AFIOPNetworkData> </xsl:if> </xsl:template>
Can someone tell me what is going on?
-- Thanks.
Regards, Trang
--
___________________________________________
Trang Nguyen
CMS accessFIBER
Herrenberger Str. 130, CMS-AF Blg4/P2M
D-71034 Boeblingen
***
e-mail: trang_nguyen@xxxxxxxxxxx
phone: +49 7031 464-8928 telnet: 778-8928
fax: +49 7031 464-1164
___________________________________________________________________
Agilent Technologies Deutschland GmbH Sitz der Gesellschaft: Böblingen, Amtsgericht Böblingen HRB 4716
Geschäftsführer:
Hans-Günter Hohmann (Vorsitzender), Karlheinz Brüderle,
Dr. Hans-Hermann Dietrich, Reinhard Hamburger
Vorsitzender des Aufsichtsrats: Roberto Favaretto
___________________________________________________________________
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Empty node set when namespace, trang_nguyen | Thread | Re: [xsl] Empty node set when names, Joerg Heinicke |
[xsl] Empty node set when namespace, trang_nguyen | Date | [xsl] Displaying text nodes and chi, Américo Albuquerque |
Month |