By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,041 Members | 1,051 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,041 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.