View Full Version : XML generating from xsd
whoknow
09-27-2007, 05:27 AM
Hi everybody,
Can anyone please show me if there is a way (in VB6 or C#) to generate an XML as described below: :)
xmlSource.xml
<Customer>
<FName>Smith</FName>
<OAddress>123</OAddress>
<MPhone>9582536</MPhone>
</Customer>
xmlDest.xml
<User>
<FirstName>Smith</FirstName>
<OfficeAddress>123</OfficeAddress>
<MobilePhone>9582536</MobilePhone>
</User>
What I want here is generate xmlDest.xml from xmlSource.xml with different xml tags (base on xsd file). I dont want to read the xmlSource.xml file and match them tags by tags in xmlDest.xml
any help is appreciate :cool:
shyam
09-27-2007, 02:03 PM
are u looking for an xslt transformation like this
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" />
<xsl:template match="/">
<User>
<xsl:apply-templates select="/Customer" />
</User>
</xsl:template>
<xsl:template match="/Customer">
<FirstName><xsl:value-of select="FName" /></FirstName>
<OfficeAddress><xsl:value-of select="OAddress" /></OfficeAddress>
<MobilePhone><xsl:value-of select="MPhone" /></MobilePhone>
</xsl:template>
</xsl:stylesheet>
whoknow
09-28-2007, 11:44 AM
Hi shyam,
thx for your help , I try to link the stylesheet to the xml file , but when I open it in the browser , the output is like below (only text), not the xmlDes structure that I want
Smith 123 9582536
I also try to look for xml to xml transformation in google but no luck , they always link me to xml to XHTML transformation :confused:
Alex Vincent
10-02-2007, 12:47 AM
Are you sure that it isn't text? Without a CSS stylesheet, the only thing you'll actually see in the browser is text, and the elements themselves will be non-visible.
Try looking at the generated source (in Firefox's menu: View, Page Source).
whoknow
10-02-2007, 03:23 AM
hi Alex Vincent,
thx for your help, I've found out that using xmlDom.TransformNodeToObject can solve my prob . But I still have one question : do you mean that if I link the xsl:stylesheet into the xml file and open the file directly in browser it'll only show me the text , also when I viewed source the xml content is still the old structure (xmlSource.xml) not the xmlDest.xml as desired :)
Alex Vincent
10-03-2007, 07:23 AM
I'm sorry, I don't know the answer to that one. Also, on view-source, I goofed: I should have told you to use a tool like Firefox's DOM Inspector, which would show you the post-transformation results.
whoknow
10-03-2007, 10:13 AM
hi Alex Vincent,
from my testing , the DOM Inspector show the correct structure , thx again :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.