473,390 Members | 878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

How to transform xml to another format

Hi,

i would like to transform xml to another format (in doing so i loose the orignal xml format). Again i would like transform to the original XML format.

is there a way to save the xml format in some way so that u can change back to original.

Regards
Nov 28 '08 #1
8 5192
Dormilich
8,658 Expert Mod 8TB
@perlprogrammer
why do you want to do that (it's not really clear to me)? you probably have to write the "inverse" transformation file of the original one.
I think it's better to make the transformation, and if you want to apply changes to the original file, write a transformation (filter) that works on the original file.

@perlprogrammer
you save an "XML format" as a validation file (DTD, XML Schema, RelaxNG) but those are meant to check if an XML document conforms to that "format" or not.

regards
Nov 28 '08 #2
i have two systems which need the file in two different formats.
sat i have xml1
Expand|Select|Wrap|Line Numbers
  1. <root>
  2.     <data1> hi</data1>
  3.     <sub> stuff<sub>
  4. </root>

i convert it to xml2 for second system which might change the value
Expand|Select|Wrap|Line Numbers
  1. <root>
  2. <data> hi</data>
  3. </root>
  4.  
when passing back this xml2 to system 1 i need it in the xml1 format.

So if i have xslt or some custom script which convertes to format 2..is there a way to convert back to format 1....(by saying dom defination or anything?

i am not sure how to achieve this, that is why asked here?
Nov 28 '08 #3
Dormilich
8,658 Expert Mod 8TB
so you want that the xml from second system updates your original xml?
Nov 28 '08 #4
that is correct..that is exactly what i want...since the xml formats are different....not sure how to hide the information about the xml format 1 in second one and use that information when transforming back....
Nov 28 '08 #5
Dormilich
8,658 Expert Mod 8TB
I'd still do an update of xml1 with xml2. for that to work you need to include xml2 via the document()-function. works like
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="returned" select="document('xml2.xml', /root)"/>
  2. // some copy-xslt
  3. <xsl:template match="data">
  4.   <data><xsl:value-of select="$returned/data[position() = current()/position()]"/></data>
  5. </xsl:template>
note: this is a sketch, the actual implementation depends on your xml files.

regards

PS: there should be some threads around that deal with similar topics
Nov 28 '08 #6
Thanks for your reply

But still i cannot see how can i achieve the following
when i transform xml format 1 to xml format 2 so that second system would except it..change the value somehow..give back the xml format 2 to system1 who does not know anything for how to change to fomrat 1 as it does not have the data lost in first transformation.

If i do what you suggested how would i do know once the format 2 is returned back by system 2 it should be mapped to some xml in fomat 1..Hope there is better way to do it which would address my issue.
Nov 28 '08 #7
Dormilich
8,658 Expert Mod 8TB
@perlprogrammer
if you do not cross-reference your data (this can be an ID type attribute or just a preserve order/count), you will never get them updated, independent of the method you use.

if you only want to format xml2 back, no matter what changes may apply and what not, you should write the inverse transformation to xml1→xml2.

regards
Nov 28 '08 #8
jkmyoung
2,057 Expert 2GB
Maybe use namespaces?
XML namespace - Wikipedia, the free encyclopedia
Namespaces in XML 1.0 (Second Edition)
The 2nd service would have to be able to ignore xml from another namespace.
Dec 1 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Luther Baker | last post by:
My team is using the FO library to generate PDFs. We are also required to use https. The XSL transform page fed into javax.xml.transform.Transformer starts with <?xml version="1.0"?>...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
3
by: b0yce | last post by:
Hi Group, I think I have found a problem with the <xsl:element> when being transformed by the .NET xmlTransform class. When using XmlSpy for development and debugging, the <xsl:number>...
7
by: Doug Heeren | last post by:
I have the following section of VB.NET code that transforms a simple dataset into an Excel xml workbook. It works fine for < 50 rows or so, but I have about 8,000 rows I need to transform. Is there...
4
by: Cedric | last post by:
Hi, I have a function from one component that returns an XmlDocument object. I have another function in another component that takes an XmlDocument as a property. I have written an XSLT to...
7
by: n33470 | last post by:
We're in the process of migrating our projects to use VS2005 from VS2003. We have a web page that uses the XML WebControl (System.Web.UI.WebControls.Xml) to perform an XSLT tranformation by...
1
by: adi | last post by:
hello all, seems like a simple issue, but having tried several approaches with no success I am posting this question, I have a XML in one format, I want to now convert into another XML format...
2
by: =?Utf-8?B?S2lt?= | last post by:
HowHi all I want to transform data in xml files to *.txt in a C# application. I have some data in Xml files and want to used them in a 3D tool to print the subject I know little about XSLT, so...
3
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.