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

programmatically generate xsl

I am trying to write an application that will generate XSL files
(trying to automat some of my development), but am having a heck of a
time. I just don't fully grasp the namespace issues I am having.

This is what I have so far:
---------------------------------Code
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration
("1.0","UTF-8", string.Empty));
XmlNode root = doc.AppendChild(doc.CreateElement
("xsl:stylesheet","http://www.w3.org/1999/XSL/Transform"));
XmlAttribute attr = doc.CreateAttribute("version");
attr.InnerText = "1.0";
root.Attributes.Append(attr);
---------------------------------/Code

That results into this:
---------------------------------Results
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</xsl:stylesheet>
----------------------------------/Results
Not to bad, but I run into problems here:
---------------------------------Code
root = root.AppendChild(doc.CreateElement
("xsl","template", "xsl"));
--------------------------------/Code
This gives me an element that looks like this:
---------------------------------Results
<xsl:template xmlns:xsl="xsl"/>
---------------------------------/Results

Am I doing this correctly? That 'xmlns:xsl="xsl"' I don't want there.
But if I try other combination of values (("xsl","template") ||
("xsl:template") || ("xsl","template","")) I never get the
"xsl:template", just "template".
Am I making sense?

Is there a better, or right why to do something like this (Besides
string builder)? What am I doing wrong?

To the one that helps me with this problem I will give you an invisible
ring of +6 save against coding errors. (ooooo, awwwww)

Nov 12 '05 #1
5 2568
Hi,

You need to specify the URI of the 'xsl' namespace in the third argument of
CreateElement.
That is,

root = root.AppendChild(doc.CreateElement
("xsl","template", "http://www.w3.org/1999/XSL/Transform"));

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"skidz" <ro*************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am trying to write an application that will generate XSL files
(trying to automat some of my development), but am having a heck of a
time. I just don't fully grasp the namespace issues I am having.

This is what I have so far:
---------------------------------Code
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration
("1.0","UTF-8", string.Empty));
XmlNode root = doc.AppendChild(doc.CreateElement
("xsl:stylesheet","http://www.w3.org/1999/XSL/Transform"));
XmlAttribute attr = doc.CreateAttribute("version");
attr.InnerText = "1.0";
root.Attributes.Append(attr);
---------------------------------/Code

That results into this:
---------------------------------Results
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</xsl:stylesheet>
----------------------------------/Results
Not to bad, but I run into problems here:
---------------------------------Code
root = root.AppendChild(doc.CreateElement
("xsl","template", "xsl"));
--------------------------------/Code
This gives me an element that looks like this:
---------------------------------Results
<xsl:template xmlns:xsl="xsl"/>
---------------------------------/Results

Am I doing this correctly? That 'xmlns:xsl="xsl"' I don't want there.
But if I try other combination of values (("xsl","template") ||
("xsl:template") || ("xsl","template","")) I never get the
"xsl:template", just "template".
Am I making sense?

Is there a better, or right why to do something like this (Besides
string builder)? What am I doing wrong?

To the one that helps me with this problem I will give you an invisible
ring of +6 save against coding errors. (ooooo, awwwww)


Nov 12 '05 #2
This is quite masochistic compared to generating xslt stylesheets using ...
XSLT.
Cheers,
Dimitre Novatchev.

"skidz" <ro*************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am trying to write an application that will generate XSL files
(trying to automat some of my development), but am having a heck of a
time. I just don't fully grasp the namespace issues I am having.

This is what I have so far:
---------------------------------Code
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration
("1.0","UTF-8", string.Empty));
XmlNode root = doc.AppendChild(doc.CreateElement
("xsl:stylesheet","http://www.w3.org/1999/XSL/Transform"));
XmlAttribute attr = doc.CreateAttribute("version");
attr.InnerText = "1.0";
root.Attributes.Append(attr);
---------------------------------/Code

That results into this:
---------------------------------Results
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</xsl:stylesheet>
----------------------------------/Results
Not to bad, but I run into problems here:
---------------------------------Code
root = root.AppendChild(doc.CreateElement
("xsl","template", "xsl"));
--------------------------------/Code
This gives me an element that looks like this:
---------------------------------Results
<xsl:template xmlns:xsl="xsl"/>
---------------------------------/Results

Am I doing this correctly? That 'xmlns:xsl="xsl"' I don't want there.
But if I try other combination of values (("xsl","template") ||
("xsl:template") || ("xsl","template","")) I never get the
"xsl:template", just "template".
Am I making sense?

Is there a better, or right why to do something like this (Besides
string builder)? What am I doing wrong?

To the one that helps me with this problem I will give you an invisible
ring of +6 save against coding errors. (ooooo, awwwww)

Nov 12 '05 #3
Dmytro Lapshyn, Thx I will give that a try. I will email you the ring
as soon as I find it. :)

Dimitre Novatchev, I thought about doing that, but how do you escape
the xsl nodes you want to output, so they are not executed in the
transformation? I have never tried it so if the question is stupid you
have my permission to slap me.

Nov 12 '05 #4

"skidz" <ro*************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Dmytro Lapshyn, Thx I will give that a try. I will email you the ring
as soon as I find it. :)

Dimitre Novatchev, I thought about doing that, but how do you escape
the xsl nodes you want to output, so they are not executed in the
transformation? I have never tried it so if the question is stupid you
have my permission to slap me.


No the question is not stupid.

Read about the

"xsl:namespace-alias"

element.

Cheers,
Dimitre Novatchev
Nov 12 '05 #5
Dimitre Novatchev, That is perfect. I tried searching google for xsl to
xsl and could never find anything good. Thx
I can now stop being so masochistic.

Dmytro Lapshyn, your solution worked great also.

Nov 12 '05 #6

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

Similar topics

4
by: Thomas Jespersen | last post by:
Hello I want to create a MSI file programmatically. Do you know of any third party .NET component which can help me with that? I'm going to use it like a self extracting zip. So it is not...
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
6
by: Null Reference | last post by:
Anybody here who can explain or point me to a link ? I wish to create a blank MS Access DB file programmatically using C# . Thanks, nfs
1
by: Arpan | last post by:
The following ASPX code snippet creates a DataSet programmatically right from the scratch: 'create an empty DataSet Dim objDS As New DataSet("MyDataSet") 'create a new table & add columns Dim...
2
by: jjack100 | last post by:
In asp.net 2.0 you can apply custom themes based on a user profile, etc. And you can change the theme programmatically, etc. But how do you edit or create a theme programmatically? I am working on...
2
by: Thu | last post by:
I store me reporting data in MS Access table, and I need to programmatically generate XML file (in text) that loads these data, include all these data with appropriate definition, i.e. root,...
2
by: Martin Widmer | last post by:
Hi guys I am looking for the best way to generate new reports with reporting services for SQL server 2005. The reports will be generated programmatically from a .Net VB application. So far I see...
0
by: Ramesh2006 | last post by:
Hi, The following error occurred when i programmatically compile another project from my present project. The Error: error CS0234:The type or namespace name 'Windows' does not exist in the...
4
by: Jay Hamilton | last post by:
Hello, I'm looking for a simple way to programmatically generate thumbnails from uploaded jpgs in PHP. It doesn't need to be too fancy either. Any thoughts? Thanks, Jay
0
by: =?Utf-8?B?WmVk?= | last post by:
Good Day, I been looking for a day now and I couldn't find a good source of information. I have a one of a kind report wherein the RDLC file including all controls are programmatically generated...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?

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.