Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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)


Report this thread to moderator Post Follow-up to this message
Old Post
skidz
05-06-05 08:58 PM


Re: programmatically generate xsl
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" <robert.skidmore@gmail.com> wrote in message
news:1115270941.483975.315430@z14g2000cwz.googlegroups.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)
>


Report this thread to moderator Post Follow-up to this message
Old Post
Dmytro Lapshyn [MVP]
05-06-05 08:58 PM


Re: programmatically generate xsl
This is quite masochistic compared to generating xslt stylesheets using ...
XSLT.


Cheers,
Dimitre Novatchev.

"skidz" <robert.skidmore@gmail.com> wrote in message
news:1115270941.483975.315430@z14g2000cwz.googlegroups.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)
>



Report this thread to moderator Post Follow-up to this message
Old Post
Dimitre Novatchev
05-09-05 01:57 AM


Re: programmatically generate xsl
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" <robert.skidmore@gmail.com> wrote in message
news:1115270941.483975.315430@z14g2000cwz.googlegroups.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)
>


Report this thread to moderator Post Follow-up to this message
Old Post
Dmytro Lapshyn [MVP]
05-09-05 01:58 PM


Re: programmatically generate xsl
"skidz" <robert.skidmore@gmail.com> wrote in message
news:1115315269.625721.282610@g14g2000cwa.googlegroups.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



Report this thread to moderator Post Follow-up to this message
Old Post
Dimitre Novatchev
05-10-05 08:58 PM


Re: programmatically generate xsl
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.


Report this thread to moderator Post Follow-up to this message
Old Post
skidz
05-11-05 09:00 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C# archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:53 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.