473,382 Members | 1,563 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,382 software developers and data experts.

Do I use xslt or xsd schemas to transform input XML to output XML with the users changes?

sam
Hi, I've been buried in xsl and xslt articles for several days now, and am
still unsure as to what I need to do...

Basically, my vb.net app loads up an XML file from an external source
(Input.xml). When the user is setting up the source, they can make changes
to it to specify which columns to include for use in my app, they can rename
columns, they can mark a column as being of a known datatype (my own custom
datatypes, e.g. a Tree).

This needs to produce an output.xml file for use in my app. So the changes
they make do not affect the original input.xml.

I need to store their changes in some way (Change.xml or .xsl), so that next
time the app loads, it will read Input.xml, apply the change instructions in
Change.xsl, and produce Output.xml automatically.

My plan is to programmatically write the changes they have specified as an
xsl file. I.e, if they have renamed a column, I programmatically add the
equivalent xslt rename element instructions to the xsl file; if they've
specified a known datatype for a column, I programmatically write the xslt
to define the complex type and specify this element as being of this type.

When the app loads, I simply call:

dim doc as XmlDocument = new XmlDocument("Input.xml")
dim xslt as XslTransform = new XslTransform("Change.xsl")
dim reader as XmlReader = xsl.Transform(doc, null)
doc.Load(reader)

Questions

1. Can I use xslt to make transformations of this type (removing columns,
renaming columns, specifying datatypes) ?

2. Instead of trying to write the Change.xsl file programmatically using
vb.net, could I load the input.xml into a dataset, make the changes to the
dataset (this is easier to do in code than manually writing an xsl file),
then use the methods of the Dataset class to automatically generate my
change.xsl somehow?

3. Am I barking up the wrong tree with xslt, and would using xsd schemas be
more applicable?

4. What do you think of my methodology, would you do it this way?
Thank you

Sam
Nov 11 '05 #1
2 6592
In line.
Sergey
--
This posting is provided "AS IS" with no warranties, and confers no rights.

"sam" <IN*****@NOSPAM.com> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
1. Can I use xslt to make transformations of this type (removing columns,
renaming columns, specifying datatypes) ? Yes you can. XSLT is generic tree transformation language.
2. Instead of trying to write the Change.xsl file programmatically using
vb.net, could I load the input.xml into a dataset, make the changes to the
dataset (this is easier to do in code than manually writing an xsl file),
then use the methods of the Dataset class to automatically generate my
change.xsl somehow? Dataset doesn't have functionality for generating XSLT that implement the
changes.
It can generate XML that represent current chages. Not sure this helps you.
3. Am I barking up the wrong tree with xslt, and would using xsd schemas be more applicable? I don't understand the questions. If you afraid that imput.xml can have
wrong schema you can validate it before transformation.
4. What do you think of my methodology, would you do it this way?

It sounds very reasonable.
It may be more complicated than it looks at the beginning. For example two
issues:
a) User renamed first of five nodes <Prose/> to <Poetry/>. In XSLT you
record this as match="Prose" or match="Prose[1]"
b) Users changes are applied to previous changes. He/she renamed <Poetry/>
to <Music/>. Do suppose to merge all such conflicts (may be not trivial) or
you prefer apply them one on top of another (it's possible).
Actually you meet such problems with or without XSLT.

Good luck.
Nov 11 '05 #2
sam

Thank you for your reply Sergey, sorry for the delay.

Your comments are very useful and encouraging. I'll let you know how I get
on. I am planning on driving my entire application via XML and XSL

cheers

Sam

"Sergey Dubinets" <sd**@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
In line.
Sergey
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"sam" <IN*****@NOSPAM.com> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
1. Can I use xslt to make transformations of this type (removing columns, renaming columns, specifying datatypes) ? Yes you can. XSLT is generic tree transformation language.

2. Instead of trying to write the Change.xsl file programmatically using
vb.net, could I load the input.xml into a dataset, make the changes to the dataset (this is easier to do in code than manually writing an xsl file), then use the methods of the Dataset class to automatically generate my
change.xsl somehow?

Dataset doesn't have functionality for generating XSLT that implement the
changes.
It can generate XML that represent current chages. Not sure this helps

you.

3. Am I barking up the wrong tree with xslt, and would using xsd schemas

be
more applicable?

I don't understand the questions. If you afraid that imput.xml can have
wrong schema you can validate it before transformation.

4. What do you think of my methodology, would you do it this way?

It sounds very reasonable.
It may be more complicated than it looks at the beginning. For example two
issues:
a) User renamed first of five nodes <Prose/> to <Poetry/>. In XSLT you
record this as match="Prose" or match="Prose[1]"
b) Users changes are applied to previous changes. He/she renamed <Poetry/>
to <Music/>. Do suppose to merge all such conflicts (may be not trivial)

or you prefer apply them one on top of another (it's possible).
Actually you meet such problems with or without XSLT.

Good luck.

Nov 11 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
1
by: Wil | last post by:
I'm very new to developing in .NET and even newer to XML. The past few days have been pretty frustrating for me because I'm trying to perform a transform on data in a dataset and it's not working....
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
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...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
4
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output...
1
by: Nick | last post by:
I am working on a website for a client and one of their requirements was to have a mailing list. I decided to XSLT to transform "templates" to HTML so that editing was very easy and less time...
4
by: =?Utf-8?B?REZC?= | last post by:
Within an XSLT transformation, I'm trying to switch the default namespace within a section of the generated XML document to a shared namespace. This way, the content of this section does not have...
3
by: joelkeepup | last post by:
Hi, im trying to create a text email message using xslt template , the transforms work great, but the newlines and whitespace in the xslt doc are removed. Is there a setting somewhere I have...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.