problem craeting XML using XSLT

Oxygen general issues.
vpsreejith1
Posts: 2
Joined: Thu Aug 09, 2007 10:26 am

problem craeting XML using XSLT

Post by vpsreejith1 »

input XML
<?xml version="1.0" eitemoding="UTF-8"?>
<!--
Example of payload body for World CUD transaction v 0.1
-->
<object type="Sony World SO" root="yes" action="Update" name="Test World" id="World FNN Value" item_id="23421354325432">
<property name="World FNN" item_id="89237498237" action="Update">
<value>ACDAF89127349812</value>
<old_value>itemSWHFC1982743982</old_value>
</property>
<property name="Sony World Name" item_id="12324545" action="Update">
<value>Honda motors</value>
<old_value>Honda</old_value>
</property>
<property name="Sony World Number Range" item_id="8763245" action="Update">
<value>13123123-14381283</value>
<old_value>123213123-124758789</old_value>
</property>
<property name="Customer Domain Names" item_id="87463298764" action="Update">
<value>honda.com.au</value>
<old_value>honda.com</old_value>
</property>
<property name="Zone Name" item_id="76524532846" action="Update">
<value>com.au</value>
<old_value>com</old_value>
</property>
<property name="Zone Primary Interface" item_id="89632876R8723" action="Update">
<value>eth0</value>
<old_value>eth1</old_value>
</property>
<property name="Zone Primary Interface" item_id="87634876327" action="Update">
<value>eth1</value>
<old_value>eth2</old_value>
</property>
<property name="CE to Zone Route IP Address" item_id="13242345235" action="Update">
<value>192.168.3.3</value>
<old_value>192.123.3.3</old_value>
</property>
<property name="Zone IP Address" item_id="345324132" action="Update">
<value>12.12.12.12</value>
<old_value>12.12.12.11</old_value>
</property>
<property name="Zone Network IP Address" item_id="32424555555" action="Update">
<value>12.12.12.10</value>
<old_value>12.12.12.13</old_value>
</property>
<property name="Zone IP Netmask" item_id="234324324" action="Update">
<value>12.12.12.9</value>
<old_value>12.12.12.14</old_value>
</property>
<property name="VLAN Interface IP Address" item_id="2567666543" action="Update">
<value>12.12.12.8</value>
<old_value>12.12.12.15</old_value>
</property>
<property name="VLAN ID" item_id="3254325435" action="Update">
<value>itemC</value>
<old_value>item</old_value>
</property>
<property name="Broadcast IP Address" item_id="3214234324" action="Update">
<value>12.12.12.255</value>
<old_value>12.12.12.254</old_value>
</property>
<property name="Customer SRC NAT Address" item_id="2342342345" action="Update">
<value>12.12.12.2</value>
<old_value>12.12.12.122</old_value>
</property>
<property name="CE Router Interface Address" item_id="2423453244" action="Update">
<value>12.12.12.1</value>
<old_value>12.12.12.19</old_value>
</property>
<property name="Exclusion Status" item_id="2342342344" action="Update">
<value>COMPLETE</value>
<old_value>INPROC</old_value>
</property>
<property name="Default Customer Domain Name" item_id="3265376345" action="Update">
<value>honda.com.au</value>
<old_value>honda.com</old_value>
</property>
<object type="World Administrator CO" root="yes" action="Create" name="World Admin 1" id="World Admin 1" item_id="23421354325432">
<property name="Administrator's Initial Password" item_id="89237498237" action="Create">
<value>G_ERd2342kf</value>
<old_value/>
</property>
<property name="Language" item_id="89237498237" action="Update">
<value>russian</value>
<old_value/>
</property>
<property name="User First Name" item_id="89237498237" action="Update">
<value>Andy</value>
<old_value/>
</property>
<property name="User Last Name" item_id="89237498237" action="Update">
<value>Titeren</value>
<old_value/>
</property>
<property name="Administrator User id" item_id="89237498237" action="Update">
<value>Titeren</value>
<old_value/>
</property>
<property name="Password reset only" item_id="89237498237" action="Update">
<value>1</value>
<old_value/>
</property>
</object>
</object>


----------------------------------------------
XSLT using


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


<xsl:template match = "/">
<xsl:apply-templates/>
</xsl:template>


<xsl:template match = "property">
<xsl:text disable-output-escaping="yes"><</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text disable-output-escaping="yes">></xsl:text>
<xsl:value-of select="value"/>
<xsl:text disable-output-escaping="yes" ></</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text disable-output-escaping="yes"> > </xsl:text>
<xsl:apply-templates select="property" />
</xsl:template>


<xsl:template match ="object">
<xsl:text disable-output-escaping="yes"><</xsl:text>
<xsl:value-of select="@type"/>
<xsl:text disable-output-escaping="yes">></xsl:text>
<xsl:apply-templates select = "property" />
<xsl:apply-templates select = "object" />
<xsl:text disable-output-escaping="yes"></</xsl:text>
<xsl:value-of select ="@type"/>
<xsl:text disable-output-escaping="yes">></xsl:text>
</xsl:template>



</xsl:stylesheet>
___________________________________________



i am getting the output XML as


<?xml version="1.0" eitemoding="UTF-8"?>
<SonyWorldSO>


<World FNN>ACDAF89127349812</World FNN >
<Sony World Name>Honda motors</Sony World Name >
<Sony World Number Range>13123123-14381283</Sony World Number Range >
<Customer Domain Names>honda.com.au</Customer Domain Names >
<Zone Name>com.au</Zone Name >
<Zone Primary Interface>eth0</Zone Primary Interface >
<Zone Primary Interface>eth1</Zone Primary Interface >
<CE to Zone Route IP Address>192.168.3.3</CE to Zone Route IP Address >
<Zone IP Address>12.12.12.12</Zone IP Address >
<Zone Network IP Address>12.12.12.10</Zone Network IP Address >
<Zone IP Netmask>12.12.12.9</Zone IP Netmask >
<VLAN Interface IP Address>12.12.12.8</VLAN Interface IP Address >
<VLAN ID>itemC</VLAN ID >
<Broadcast IP Address>12.12.12.255</Broadcast IP Address >
<Customer SRC NAT Address>12.12.12.2</Customer SRC NAT Address >
<CE Router Interface Address>12.12.12.1</CE Router Interface Address >
<Exclusion Status>COMPLETE</Exclusion Status >
<Default Customer Domain Name>honda.com.au</Default Customer Domain Name >


<World Administrator CO>


<Administrator's Initial Password>G_ERd2342kf</Administrator's Initial Password >
<Language>russian</Language > <User First Name>Andy</User First Name >
<User Last Name>Titeren</User Last Name >
<Administrator User id>Titeren</Administrator User id >
<Password reset only>1</Password reset only >


</World Administrator CO>


</Sony World SO>
-------------------------------------------------
you can see the xml output is not a valid one as there is space inside the same node


like <Sony World SO>
<World Administrator CO>
<World FNN>
<Sony World Name>
<Sony World Number Range>
<Customer Domain Names>


and so on
but as in xml space not allowed inside nodes
it should me
<SonyWorldSO>
<WorldAdministratorCO>
<WorldFNN>
<SonyWorldName>
<SonyWorldNumberRange>
<CustomerDomainNames>


how to change the XSLT to get the output like above.


i tried to solve the issue with
<xsl:strip-space elements="*"> or <xsl:strip-space elements="object">
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

Post by kingargyle »

You need to use something like the translate() xpath function, to translate teh spaces to either nulls or somethingelse.

something like

<xsl:value-of select="translate($yourdata, " ", "")"/>
Post Reply