Problem while transforming an XML into another XML file
Posted: Tue Apr 25, 2006 11:21 am
Hi everyone !
I post here because I am facing some filtering problem: I want to transform an XML to another one. The output should only take some of the data of the input one and the other element of the input should be ignored.
Here is the input xml file I use:
The XSL file I have defined:
The output of the transformation is:
This means that the template matches everything.
Is there a way to prevent that the last template does not overide the the other when they are applicable ?
I have tried to tune with priority but without any success
The expected output should be
I post here because I am facing some filtering problem: I want to transform an XML to another one. The output should only take some of the data of the input one and the other element of the input should be ignored.
Here is the input xml file I use:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Network_Fulfilment_Request xmlns="http://mobile.belgacom.be/fiona/xml/cl">
<Body>
<Registered_End_User>
<REU_ID>
<ID>1245</ID>
</REU_ID>
<Details>
<Gender>false</Gender>
</Details>
</Registered_End_User>
<Subscription>
<Product_Subscriptions>
<Installed_CFSs>
<CFS>
<CFS_Identifier>12</CFS_Identifier>
<Description>description</Description>
<Action>U</Action>
</CFS>
<CFS_Parameter>
<Parameter_Type_ID>NetworkID</Parameter_Type_ID>
<Parameter_Value>netw0</Parameter_Value>
</CFS_Parameter>
<CFS_Parameter>
<Parameter_Type_ID>TransactionID</Parameter_Type_ID>
<Parameter_Value>123456789</Parameter_Value>
</CFS_Parameter>
<CFS_Parameter>
<Parameter_Type_ID>IsMobile</Parameter_Type_ID>
<Parameter_Value>0</Parameter_Value>
</CFS_Parameter>
</Installed_CFSs>
</Product_Subscriptions>
</Subscription>
</Body>
</Network_Fulfilment_Request>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns="http://mobile.belgacom.be/fiona/xml"
xmlns:cl="http://mobile.belgacom.be/fiona/xml/cl">
<xsl:template match="/">
<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mobile.belgacom.be/fiona/xml file:/C:/Workspace/Fiona/trunk/xsd/request.xsd">
<xsl:apply-templates/>
</request>
</xsl:template>
<xsl:template match="cl:Action" priority="0.5">
<param>
<key>REQ_TYPE</key>
<value>
<xsl:value-of select="."/>
</value>
</param>
</xsl:template>
<xsl:template match="cl:CFS_Parameter" priority="0.5">
<param>
<key>
<xsl:value-of select="cl:Parameter_Type_ID"/>
</key>
<value>
<xsl:value-of select="cl:Parameter_Value"/>
</value>
</param>
</xsl:template>
<xsl:template match="*" priority="0.1"/>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<request xmlns="http://mobile.belgacom.be/fiona/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cl="http://mobile.belgacom.be/fiona/xml/cl"
xsi:schemaLocation="http://mobile.belgacom.be/fiona/xml file:/C:/Workspace/Fiona/trunk/xsd/request.xsd"/>
Code: Select all
<xsl:template match="*" priority="0.1"/>
Is there a way to prevent that the last template does not overide the the other when they are applicable ?
I have tried to tune with priority but without any success

The expected output should be
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<request xmlns="http://mobile.belgacom.be/fiona/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cl="http://mobile.belgacom.be/fiona/xml/cl"
xsi:schemaLocation="http://mobile.belgacom.be/fiona/xml file:/C:/Workspace/Fiona/trunk/xsd/request.xsd">
<param><key>REQ_TYPE</key><value>U</value></param>
<param><key>NetworkID</key><value>netw0</value></param>
<param><key>TransactionID</key><value>123456789</value></param>
<param><key>IsMobile</key><value>0</value></param>
</request>