programmatically generate xsl

  • Thread starter Thread starter skidz
  • Start date Start date
S

skidz

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)
 
This is quite masochistic compared to generating xslt stylesheets using ...
XSLT.


Cheers,
Dimitre Novatchev.
 
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.
 
skidz said:
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
 
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.
 
Back
Top