 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 7th, 2011, 10:28 AM
|
|
Authorized User
|
|
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Running as part of c# program
Hi,
I have writeen an XSLT transform , which uses the document function to load in config data.
i then run the transform using the c# classes and output the xml to another file.
I have set the XsltSetting to enable documentFunction, and when i run through the debugger (visual studio 2010) then the config file is successfully loaded in and the config items are correctly used.
However, when i run as part of the c# program, the transform successfully runs (ie not error/ exception thrown) but the output is incorrect as the xconfig items have been ignored; its like they are not there
please advise
thanks
|
|

December 7th, 2011, 10:34 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Perhaps if you could us with a sample of the code, as it is virtually impossible to tell from your description what you might be doing wrong.
|
|

December 7th, 2011, 10:36 AM
|
|
Authorized User
|
|
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Code:
<xsl:template name = "Lookup_ndf_Currency_from_ConfigFile" >
<xsl:param name ="curr" />
<xsl:for-each select ="document('config.xml')/FXConnect2FpMLConfig/ndf_currency/currency">
<xsl:if test = "$curr = @name">
<xsl:value-of select ="'true'"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
c# code to call the transform
Code:
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(sXslPath, new System.Xml.Xsl.XsltSettings(true, false), new XmlUrlResolver());
using (StringWriter sw = new StringWriter())
{
xslt.Transform(xri, null, sw);
...
...
|
|

December 7th, 2011, 10:57 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Where is the 'config.xml' file located, in the same directory as the XML input, in the same directory as the stylesheet, are these two in the same directory?
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|

December 7th, 2011, 10:58 AM
|
|
Authorized User
|
|
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
same directory as the stylesheet
|
|

December 7th, 2011, 11:14 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
I can't see anything wrong with your code. You should get an error if it can't find the config, but you wouldn't get an error if the config file it found didn't contain the element you are selecting in the xpath.
|
|
The Following User Says Thank You to samjudson For This Useful Post:
|
|
|

December 12th, 2011, 08:36 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Can you show the structure of config.xml?
|
|
 |