XSLT with external XML reference (C#)

Greeting :-)
I'm not sure whether this is an XML/XSLT problem, or a C# problem...

I have implemented an XML file, XSL file (which references an external XML file), which works perfectly when run through IE. However I'm not getting the same result when I'm using it through C#.

It's difficult to explain, so let me give more detail:
I have an XML file called "actions.xml" which contains all the preferences for available actions in my web application...<Actions>
<Action>
<Name>ViewUsers<Name>
<Title>View All Users</Title>
</Action>
...
</Actions>
I also have a XML which controls the displaying of a button bar called "buttons.xml"...<Buttons>
<Button action="ViewUsers"/>
...
</Buttons>
And I have an XSL file "buttons.xsl" which should transform "buttons.xml" to contain the Title text from "actions"...
<xsl:variable name="actionsxml" select="document('actions.xml')"/>
...
<xsl:value-of select="$actionsxml//Title[../Name=@action]"/>
Running this directly through IE works correctly, and "View All Users" is displayed.

However, by tranforming it through the XslTransform class in C# I'm not getting the text through...XslTransform xslTransDoc = new XslTransform();
xslTransDoc.Load( "buttons.xsl" );
xslTransDoc.Transform( "buttons.xml", "buttons_trans.xml", null );Is there something I'm missing? Do I have to pre-load the external XML? Should have I used more salt?

Any help would be greatly appreciated,
Tom :-)

[Andreas]: Being naughty as well and removed link to other thread... :cool:
[1761 byte] By [tom hartland] at [2007-11-18 19:03:30]
# 1 Re: XSLT with external XML reference (C#)
The action.xml file should look something like
<Actions>
<Action>
<Name>ViewUsers<Name>
<Title action="ViewUsers">View All Users</Title>
</Action>
</Actions>

To match the xpath expression in the stylesheet, I can't really say much else.
khp at 2007-11-10 3:28:14 >
# 2 Re: XSLT with external XML reference (C#)
Following up my original posting...
(Because I know how irritating it is to find a thread you think will answer your question, but hasn't got a follow-up.)

Thank you for your reply khp, but unfortunately that hasn't solved it. I fact I haven't manage to solve it at all. :(

Due to the size that "actions.xml" has now reached, it was becoming obvious that the XSL processing required was far too much of an overhead for my needs.
I am now manually processing the "buttons.xml" file, and holding the converted contents of "actions.xml" in the Cache (ASP.NET), referencing it when required.

If anybody does get round to solving the original problem, I'd love to know how - from a personal point of view (and possible future use).

Cheers,
Tom :)
tom hartland at 2007-11-10 3:29:14 >
# 3 Re: XSLT with external XML reference (C#)
Originally posted by tom hartland
Thank you for your reply khp, but unfortunately that hasn't solved it.

I figured as much. To solve the problem I would have to consult the C# documentation, for it's support for the xslt document() function. I'am not a C# kind of guy, so there is absolutly no way I'am going to do that.
I suppose it could be as simple as explicitly stating the protocol by which the file should be loaded something like document('file://actions.xml') or using absolute paths instead of relative paths (assuming that C# looks for the file relative to the program rather than relative to the buttons.xml). It might even be that C# uses a special protocol for accessing files already loaded into C#.

As I said, the only way to find the answers to these things is to read the documentation.
khp at 2007-11-10 3:30:12 >
# 4 Re: XSLT with external XML reference (C#)
Please check.

This was known bug in .Net Framework 1.1

http://support.microsoft.com/default.aspx?scid=kb;EN-US;325692
nikhilach at 2007-11-10 3:31:13 >