Dave,

pls. find attached the .xsl file.

Thanks,
Indrajit
 


On Tue, 06 Mar 2007 David Bertoni wrote :
>Indrajit Bhattacharya wrote:
>>Hi Dave,
>>
>>Awaiting your reply.
>
>And still you did not show us the stylesheet, so I have no idea what might be 
>going on.  Also, I have no idea why using the Xerces-C wrapper would result in 
>different behavior.  It could be a bug in the Xalan-C wrapper classes, or it 
>could be a bug in your code.  I just don't have enough information to answer 
>your question.
>
>>Another query: When I call writeToString() method of the DOMDocument and pass 
>>a DOMNode to the function, the resulting string gives the string equivalent 
>>of the DOM node, but it also gives the namespaces information as xmlns 
>>attribute. This I want to avoid. Please tell me how to do that.
>>I am posting it here, as I did not find any other user group that I can post 
>>there; I did not get the URL to subscibe to the xerces user list as well.
>
>You should subscribe to the Xerces-C user mailing list:
>
>http://xml.apache.org/mail.html#xerces-c-user
>
>However, what you want do do is not possible using any standard XML 
>serializer, since the namespace information is an intrinsic part of the 
>document.
>
>Dave
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:nsp="http://www.nspconsortium.org/XMLSchema/nsp/1.4";>

<xsl:output method="xml" indent="yes"/>




<xsl:template match="@*|node()">
	<xsl:copy>
		<xsl:apply-templates select="@*"/>
		 <xsl:apply-templates/>
	</xsl:copy>
</xsl:template>


<xsl:template match="nsp:component/nsp:model/nsp:ports">
	<xsl:element name="nsp:signals">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>	
</xsl:template>



<xsl:template match="nsp:component/nsp:model/nsp:ports/nsp:port/nsp:constraintSets">
	<xsl:element name="nsp:signalConstraintSets">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:component/nsp:model/nsp:ports/nsp:port/nsp:portConstraintSets/nsp:constraints">
	<xsl:element name="nsp:signalConstraints">
		<xsl:apply-templates select="@*"/>
		<xsl:if test="@nsp:constraintSetId = '' or @nsp:constraintSetId = 'default' ">
			<xsl:attribute name="nsp:constraintSetId">default</xsl:attribute>
		</xsl:if>
		<xsl:apply-templates/>
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:component/nsp:model/nsp:ports/nsp:port">
	<xsl:element name="nsp:signal">
		<xsl:apply-templates select="nsp:name"/>
		<xsl:apply-templates select="nsp:direction"/>
		<xsl:if test="nsp:vector">
			<!-- skip it -->
				<xsl:apply-templates select="nsp:left"/>
				<xsl:apply-templates select="nsp:right"/>
		</xsl:if>
		<xsl:if test="nsp:driver">
			<!-- skip it -->
				<xsl:apply-templates select="nsp:defaultValue"/>
				<xsl:apply-templates select="nsp:clockDriver"/>
				<xsl:apply-templates select="nsp:singleShotDriver"/>
		</xsl:if>
		<xsl:apply-templates select="nsp:export"/>
		<xsl:apply-templates select="nsp:signalConstraintSets"/>
		<xsl:apply-templates select="nsp:vendorExtensions"/>
	</xsl:element>	
</xsl:template>



<xsl:template match="nsp:component/nsp:busInterfaces/nsp:busInterface/nsp:portMap">
	<xsl:element name="nsp:signalMap">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>	
</xsl:template>



<xsl:template match="nsp:component/nsp:busInterfaces/nsp:busInterface/nsp:portMap/nsp:portName/nsp:componentPortName">
	<xsl:element name="nsp:componentSignalName">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>	
</xsl:template>



<xsl:template match="nsp:component/nsp:busInterfaces/nsp:busInterface/nsp:portMap/nsp:portName/nsp:busPortName">
	<xsl:element name="nsp:busSignalName">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>	
</xsl:template>



<xsl:template match="nsp:component/nsp:busInterfaces/nsp:busInterface/nsp:portMap/nsp:portName">
	<xsl:element name="nsp:signalName">
		<xsl:apply-templates select="nsp:componentPortName"/>
		<xsl:apply-templates select="nsp:busPortName"/>
		<xsl:if test="nsp:vector">
				<xsl:apply-templates select="nsp:left"/>
				<xsl:apply-templates select="nsp:right"/>
		</xsl:if>
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:component/nsp:memoryMaps/nsp:memoryMap/nsp:addressBlock/nsp:register/nsp:field/nsp:bitOffset">
	<xsl:element name="nsp:bitOffset"><xsl:value-of select="."/></xsl:element>
</xsl:template>



<xsl:template match="nsp:component/nsp:memoryMaps/nsp:memoryMap/nsp:addressBlock/nsp:register/nsp:field/nsp:values/nsp:value">
	<xsl:element name="nsp:value"><xsl:value-of select="."/></xsl:element>
</xsl:template>



<xsl:template match="nsp:design/nsp:adHocConnections/nsp:adHocConnection/nsp:portReference">
	<xsl:element name="nsp:pinReference">
		<xsl:apply-templates select="@nsp:componentRef"/>
		<xsl:attribute name="nsp:signalRef"><xsl:value-of select="@nsp:portRef"/></xsl:attribute>
		<xsl:apply-templates select="@nsp:left"/>
		<xsl:apply-templates select="@nsp:right"/>
	</xsl:element>
</xsl:template>


<xsl:template match="nsp:busDefinition/nsp:ports">
	<xsl:element name="nsp:signals">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>	
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:busDefinition/nsp:ports/nsp:port">
	<xsl:element name="nsp:signal">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>	
	</xsl:element>
</xsl:template>




<xsl:template match="nsp:busDefinition/nsp:signals/nsp:signal/*/nsp:width">
	<xsl:element name="nsp:bitWidth">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>	
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:busDefinition/nsp:signals/nsp:port/nsp:busDefPortConstraintSets ">
	<xsl:element name="nsp:busDefSignalConstraintSets">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:busDefinition/nsp:ports/nsp:port/nsp:busDefPortConstraintSets/nsp:busDefPortConstraint">
	<xsl:element name="nsp:busDefSignalConstraints">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:busDefinition/nsp:signals/nsp:signal/nsp:defaultDriver">
	<xsl:element name="nsp:defaultValue">
		<xsl:element name="nsp:value">
			<xsl:apply-templates select="nsp:value"/>
		</xsl:element>
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:busDefinition/nsp:signals/nsp:signal/nsp:onSystem">
	<xsl:element name="nsp:onSystem">
		<xsl:choose>
			<xsl:when test="nsp:presence='illegal'">
				<xsl:attribute name="nsp:direction">illegal</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:element>
</xsl:template>

<xsl:template match="nsp:busDefinition/nsp:signals/nsp:signal/nsp:onSlave">
	<xsl:element name="nsp:onSlave">
		<xsl:choose>
			<xsl:when test="nsp:presence='illegal'">
				<xsl:attribute name="nsp:direction">illegal</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:element>
</xsl:template>

<xsl:template match="nsp:busDefinition/nsp:signals/nsp:signal/nsp:onMaster">
	<xsl:element name="nsp:onMaster">
		<xsl:choose>
			<xsl:when test="nsp:presence='illegal'">
				<xsl:attribute name="nsp:direction">illegal</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:generatorChain/nsp:generatorChainSelector">
	<xsl:element name="nsp:fileGeneratorSelector">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>	
	</xsl:element>
</xsl:template>



<xsl:template match="nsp:generatorChain/nsp:fileGeneratorSelector/nsp:generatorChainRef">
	<xsl:element name="nsp:fileName">
		<xsl:apply-templates select="@*"/>
		<xsl:apply-templates/>	
	</xsl:element>
</xsl:template>




</xsl:stylesheet>

Reply via email to