Altova Mailing List Archives


[xsl] FW: Empty node set when namespace nodes are used

From: trang_nguyen@-----------
To:
Date: 5/24/2002 1:08:00 AM
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

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.