<ShortDescription>Price for 1 .</ShortDescription>
<OurPrice>18</OurPrice>
<Weight>200</Weight>
<ManuName>JVC</ManuName>
<MainCat>EarPhones</MainCat>
<AddnlCat1>Ipod Accessories</AddnlCat1>
<AddnlCat2>Earphones</AddnlCat2>
<AddnlCat3>Audio Accessories</AddnlCat3>
<AddnlCat4>No main cat</AddnlCat4>
<AddImg1>1</AddImg1>
<AddImg2>2</AddImg2>
<AddImg3>3</AddImg3>
<MainDescription>Some description of 9000 characters</MainDescription>
<ExtraInfo>Some more information</ExtraInfo>
<Usefulinfo>Useful Information</Usefulinfo>
<Length>123</Length>
<Height>80</Height>
<Width>40</Width>
<Amp>3</Amp>
<Volt>12</Volt>
<ShpPortal>GB/KELKOO/</ShpPortal>
<catgrpid>2</catgrpid>
<PdtBarCode>12345</PdtBarCode>
<CustBarcode>12345</CustBarcode>
<IsEnabled>true</IsEnabled>
<IsDeleted>false</IsDeleted>
</WebPdts>
<WebPdts>
<ID>4156</ID>
<BaseSku>JVCHAFX3</BaseSku>
<Name>JVC In Ear Marsmallow Mouldable Stereo Headphones </Name>
<ShortDescription>JVC In Ear Marsmallow Mouldable Stereo Headphones - Blue, 1 in a Pack, Price for 1 Pack, HA-FX34-AN-E</ShortDescription>
<OurPrice>13.42</OurPrice>
<Weight>454</Weight>
<ManuName>JVC</ManuName>
<MainCat>Ipod Accessories and Earphones</MainCat>
<AddnlCat1>Earphones</AddnlCat1>
<AddImg1>0</AddImg1>
<AddImg2>0</AddImg2>
<AddImg3>0</AddImg3>
<MainDescription>JVC In Ear Marsmallow Mouldable Stereo Headphones - Blue, 1 in a Pack, Price for 1 Pack, HA-FX34-AN-E</MainDescription>
<ShpPortal>All</ShpPortal>
<catgrpid>21</catgrpid>
<PdtBarCode>4975769999949</PdtBarCode>
<IsEnabled>true</IsEnabled>
<IsDeleted>false</IsDeleted>
</WebPdts>
</NewDataSet>
xmlXML DataSet root element writexml readxmlelement Xml load only after focusxml include schemaDataTable.GetXmlflash xmlASP.NETXML controlxsltXML deserialize deploymentkml xsl xslt xml xpath string functionsxml importxml databaseXML DropDownList control DataSource XmlDataSourceXML CopyAsp.net XMLDataSetsxml data editingxml dataXML datatype columnediting xml data in xml datatype columndatsetxml appearacedatasetXML documentasp.NET 2.0xml attribute xmltextwriterXSLT Transformation javascriptRead xml fileXSLTContextXML fragmentXML caching.NET 2.0Datatablexml in .netasp net 2.0asp.net2.0Writing XMLCreating XML stringasp.net 2.0 xmlxslt xmlXML default namespacexslt asp.net control eventWriteAttributeStringdatabasexml data file translationByteArray[] to XmlDocument [Edit Tags]ByteArray[] to XmlDocument [Edit Tags] [Edit Tags] [Edit Tags]write xmlxml explicit orderingxslt visual studio 2008 xhtml validationxml editsitemap xml xmldatasource treeview NavigationUrl valuetextsqll and xmlinnerxmledi to xmlc# datatable datasource readxml readxmlschema xmldocumentXML eventsxml data into database sqlchild nodesFOR XML EXPLICIT sqlparameter DataSetADO/XMLXML datagrid asp.netXML data sourcexml grid datagrid gridviewcount XMLDataSourceempty element xmlwriter formatting full element writefullendelementXML encoding/decodingxml gridview repeater subitemsgenerating XSLTInsert Data Into Multi-Level XML fileExcel XML Formula WorksheetOptions Worksheet Table Row Cell Data StylesDOMreading xml and datasetXSLT 2.0XSLT implementationexsltxml and XmlDataSource Control and Gridview inside GridViewXML and XmlDataSource Control Gridview Master Detail
Well if we are supposed to help writing the stylesheet then we need to know how the XML output you want to create from the input you posted should look. So please post the XML you want to create as well, then we can help with the stylesheet.
Martin Honnen --- MVP Data Platform Development
My blog
Your input and output xml structure is same, the only diffrence I see is that in your input xml there are two nodes of WebPdts and in output xml you require
1 node which has WebPdts/ID = 1, on that assumption I have prepared this XSLT for you..this will produce your required output.
Thanks for the reply. The input xml is a table from database (dataset). The reason I have chose to use XSLT to get empty elements(if the value is null or empty in the database I am not geeting the column name as element) in my output xml.
Example 1#
<AddnlCat1>Ipod Accessories</AddnlCat1>
<AddnlCat2></AddnlCat2>
<AddnlCat3>Audio</AddnlCat3>
<AddnlCat4></AddnlCat4>
IN the above example I am getting the output as below (only getting the element which has value)
<AddnlCat1>Ipod Accessories</AddnlCat1>
My question is How do I get the whole structure of the dataset (weather it has empty element or not) as below
If you want to get the whole structure of the dataset then yes the one way is to apply xslt over your xml and generate the out put you want. So what is the problem you are facing? Like you dont know how to write xslt or how to apply it ?
Please mark this post as Answer if it is of help to you!
I would love to change the world, but they wont give me the source code.
SudhaYogesh
Member
7 Points
45 Posts
How to transform XML to wellformed XML using XSLT ?
Sep 04, 2009 02:28 PM|LINK
HI I have the below XML generated from dataset , but some of the elements (columns) missing because of empty value in the database.
So I have to use XSLT to transform the xml to xml to have the emptyelements. Please someone giude how do I start XSLT for the below
XML structure. It is a table about the products and no attributes and other complex stuff involved.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<NewDataSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<WebPdts>
<ID>1</ID>
<BaseSku>DD45RT</BaseSku>
<Name>JVC earphone</Name>
<ShortDescription>Price for 1 .</ShortDescription>
<OurPrice>18</OurPrice>
<Weight>200</Weight>
<ManuName>JVC</ManuName>
<MainCat>EarPhones</MainCat>
<AddnlCat1>Ipod Accessories</AddnlCat1>
<AddnlCat2>Earphones</AddnlCat2>
<AddnlCat3>Audio Accessories</AddnlCat3>
<AddnlCat4>No main cat</AddnlCat4>
<AddImg1>1</AddImg1>
<AddImg2>2</AddImg2>
<AddImg3>3</AddImg3>
<MainDescription>Some description of 9000 characters</MainDescription>
<ExtraInfo>Some more information</ExtraInfo>
<Usefulinfo>Useful Information</Usefulinfo>
<Length>123</Length>
<Height>80</Height>
<Width>40</Width>
<Amp>3</Amp>
<Volt>12</Volt>
<ShpPortal>GB/KELKOO/</ShpPortal>
<catgrpid>2</catgrpid>
<PdtBarCode>12345</PdtBarCode>
<CustBarcode>12345</CustBarcode>
<IsEnabled>true</IsEnabled>
<IsDeleted>false</IsDeleted>
</WebPdts>
<WebPdts>
<ID>4156</ID>
<BaseSku>JVCHAFX3</BaseSku>
<Name>JVC In Ear Marsmallow Mouldable Stereo Headphones </Name>
<ShortDescription>JVC In Ear Marsmallow Mouldable Stereo Headphones - Blue, 1 in a Pack, Price for 1 Pack, HA-FX34-AN-E</ShortDescription>
<OurPrice>13.42</OurPrice>
<Weight>454</Weight>
<ManuName>JVC</ManuName>
<MainCat>Ipod Accessories and Earphones</MainCat>
<AddnlCat1>Earphones</AddnlCat1>
<AddImg1>0</AddImg1>
<AddImg2>0</AddImg2>
<AddImg3>0</AddImg3>
<MainDescription>JVC In Ear Marsmallow Mouldable Stereo Headphones - Blue, 1 in a Pack, Price for 1 Pack, HA-FX34-AN-E</MainDescription>
<ShpPortal>All</ShpPortal>
<catgrpid>21</catgrpid>
<PdtBarCode>4975769999949</PdtBarCode>
<IsEnabled>true</IsEnabled>
<IsDeleted>false</IsDeleted>
</WebPdts>
</NewDataSet>
xml XML DataSet root element writexml readxml element Xml load only after focus xml include schema DataTable.GetXml flash xml ASP.NET XML control xslt XML deserialize deployment kml xsl xslt xml xpath string functions xml import xml database XML DropDownList control DataSource XmlDataSource XML Copy Asp.net XML DataSets xml data editing xml data XML datatype column editing xml data in xml datatype column datset xml appearace dataset XML document asp.NET 2.0 xml attribute xmltextwriter XSLT Transformation javascript Read xml file XSLTContext XML fragment XML caching .NET 2.0 Datatable xml in .net asp net 2.0 asp.net2.0 Writing XML Creating XML string asp.net 2.0 xml xslt xml XML default namespace xslt asp.net control event WriteAttributeString database xml data file translation ByteArray[] to XmlDocument [Edit Tags] ByteArray[] to XmlDocument [Edit Tags] [Edit Tags] [Edit Tags] write xml xml explicit ordering xslt visual studio 2008 xhtml validation xml edit sitemap xml xmldatasource treeview NavigationUrl valuetext sqll and xml innerxml edi to xml c# datatable datasource readxml readxmlschema xmldocument XML events xml data into database sql child nodes FOR XML EXPLICIT sqlparameter DataSet ADO/XML XML datagrid asp.net XML data source xml grid datagrid gridview count XMLDataSource empty element xmlwriter formatting full element writefullendelement XML encoding/decoding xml gridview repeater subitems generating XSLT Insert Data Into Multi-Level XML file Excel XML Formula WorksheetOptions Worksheet Table Row Cell Data Styles DOM reading xml and dataset XSLT 2.0 XSLT implementation exslt xml and XmlDataSource Control and Gridview inside GridView XML and XmlDataSource Control Gridview Master Detail
Martin_Honne...
Star
14481 Points
2006 Posts
MVP
Re: How to transform XML to wellformed XML using XSLT ?
Sep 04, 2009 04:04 PM|LINK
Well if we are supposed to help writing the stylesheet then we need to know how the XML output you want to create from the input you posted should look. So please post the XML you want to create as well, then we can help with the stylesheet.
My blog
SudhaYogesh
Member
7 Points
45 Posts
Re: How to transform XML to wellformed XML using XSLT ?
Sep 06, 2009 09:10 PM|LINK
Hi
Thank you verymuch for the reply.I am expecting the XML OUTPUT structure as below.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<NewDataSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<WebPdts>
<ID>1</ID>
<BaseSku>DD45RT</BaseSku>
<Name>JVC earphone</Name>
<ShortDescription>Price for 1 .</ShortDescription>
<OurPrice>18</OurPrice>
<Weight>200</Weight>
<ManuName>JVC</ManuName>
<MainCat>EarPhones</MainCat>
<AddnlCat1>Ipod Accessories</AddnlCat1>
<AddnlCat2>Earphones</AddnlCat2>
<AddnlCat3>Audio Accessories</AddnlCat3>
<AddnlCat4>No main cat</AddnlCat4>
<AddImg1>1</AddImg1>
<AddImg2>2</AddImg2>
<AddImg3>3</AddImg3>
<MainDescription>Some description of 9000 characters</MainDescription>
<ExtraInfo>Some more information</ExtraInfo>
<Usefulinfo>Useful Information</Usefulinfo>
<Length>123</Length>
<Height>80</Height>
<Width>40</Width>
<Amp>3</Amp>
<Volt>12</Volt>
<ShpPortal>GB/KELKOO/</ShpPortal>
<catgrpid>2</catgrpid>
<PdtBarCode>12345</PdtBarCode>
<CustBarcode>12345</CustBarcode>
<IsEnabled>true</IsEnabled>
<IsDeleted>false</IsDeleted>
</WebPdts>
</NewDataSet>
kavita_khand...
Star
9767 Points
1930 Posts
Re: How to transform XML to wellformed XML using XSLT ?
Sep 07, 2009 05:15 AM|LINK
Your input and output xml structure is same, the only diffrence I see is that in your input xml there are two nodes of WebPdts and in output xml you require
1 node which has WebPdts/ID = 1, on that assumption I have prepared this XSLT for you..this will produce your required output.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="NewDataSet">
<xsl:for-each select="WebPdts">
<xsl:if test="string(ID) = '1'">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
If you do not know how to apply xslt over your input xml then chekc out my blog post for the same at
http://kavstech.blogspot.com/2009/07/basic-funda-of-xmlxsdxslt.html
I would love to change the world, but they wont give me the source code.
SudhaYogesh
Member
7 Points
45 Posts
Re: How to transform XML to wellformed XML using XSLT ?
Sep 07, 2009 02:42 PM|LINK
Hi Kavita
Thanks for the reply. The input xml is a table from database (dataset). The reason I have chose to use XSLT to get empty elements(if the value is null or empty in the database I am not geeting the column name as element) in my output xml.
Example 1#
<AddnlCat1>Ipod Accessories</AddnlCat1>
<AddnlCat2></AddnlCat2>
<AddnlCat3>Audio</AddnlCat3>
<AddnlCat4></AddnlCat4>
IN the above example I am getting the output as below (only getting the element which has value)
<AddnlCat1>Ipod Accessories</AddnlCat1>
My question is How do I get the whole structure of the dataset (weather it has empty element or not) as below
<AddnlCat1>Ipod Accessories</AddnlCat1>
<AddnlCat2></AddnlCat2> -----------------Empty element--------
<AddnlCat3>Audio</AddnlCat3>
<AddnlCat4></AddnlCat4> -----------------Empty element--------
kavita_khand...
Star
9767 Points
1930 Posts
Re: How to transform XML to wellformed XML using XSLT ?
Sep 08, 2009 05:12 AM|LINK
If you want to get the whole structure of the dataset then yes the one way is to apply xslt over your xml and generate the out put you want. So what is the problem you are facing? Like you dont know how to write xslt or how to apply it ?
I would love to change the world, but they wont give me the source code.
anfran.mende...
Participant
1398 Points
241 Posts
Re: How to transform XML to wellformed XML using XSLT ?
Sep 08, 2009 05:37 AM|LINK
It is not wise to perform an xslt here, why dont you give an isnull(FieldName,'') as OutputFieldName in your Query or Stored Procedure in SQL Server
That can solve this problem and bring it in the first XML itself.
SudhaYogesh
Member
7 Points
45 Posts
Re: How to transform XML to wellformed XML using XSLT ?
Sep 08, 2009 08:28 AM|LINK
HI
Finally I have done the below changes in my query
COALESCE(FieldName,'')
Thanks for the reply. Thank you
anfran.mende...
Participant
1398 Points
241 Posts
Re: How to transform XML to wellformed XML using XSLT ?
Sep 08, 2009 08:46 AM|LINK
So you are using oracle. dont forget to Mark as Answer