XmlDataSource problem with transformation

XmlDataSource problem with transformation

am 17.01.2008 10:40:53 von Slawomir

I'm trying to use xml with included external files as data source in
xmldatasource control. Unfortunately it doesn't work. Can somebody tell
me what is wrong in this code or what I'm doing wrong? When I'm using
javascript to transform files everything work fine (correct xml is
generated) and when I set it up as data source menu works fine.


Whole solution consists of few files:
main.xml - passed as parameter (data file) to xmldatasource control
trans.xsl - defines transformation, passed as parameter (transform file)
to xmldatasource control
01.xml - first data source file
02.xml - second data source file
doc.js - additional javascript that make the transformation correctly on
my computer. Not used as a part of dataset, just help me to view the
transformation result.
executing sample: cscript doc.xml //NOLOGO >result.xml
When I pass result.xml as data file to xmldatasource menu control works
fine.

main.xml
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -





- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

trans.xsl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">













- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

01.xml
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



desc="news.onet.pl"/>


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

02.xml
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

desc="Portal informacyjny Wirtualna Polska">




- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


doc.js
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var sourceFile = ("main.xml");
var styleFile = ("trans.xsl");

// Load the XML.
var source = new ActiveXObject("Msxml2.DOMDocument.5.0");
source.async = false;
source.load(sourceFile);

// Load the XSLT.
var style =new ActiveXObject("Msxml2.DOMDocument.5.0");
style.async = false;
style.load(styleFile);

WScript.Echo(source.transformNode(style));
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

XmlDataSource control code
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DataFile="~/test2/main.xml"
EnableViewState="False"
XPath="/*/*" TransformFile="~/test2/trans.xsl">

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


Kind Regards,
Slawomir

Re: XmlDataSource problem with transformation

am 17.01.2008 19:01:03 von Martin Honnen

Slawomir wrote:
> I'm trying to use xml with included external files as data source in
> xmldatasource control. Unfortunately it doesn't work. Can somebody tell
> me what is wrong in this code or what I'm doing wrong? When I'm using
> javascript to transform files everything work fine (correct xml is
> generated) and when I set it up as data source menu works fine.
>
>
> Whole solution consists of few files:
> main.xml - passed as parameter (data file) to xmldatasource control
> trans.xsl - defines transformation, passed as parameter (transform file)
> to xmldatasource control
> 01.xml - first data source file
> 02.xml - second data source file

Where are 01.xml and 02.xml stored, are they in the same directory as
the main.xml and the trans.xsl?


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Re: XmlDataSource problem with transformation

am 17.01.2008 19:46:49 von Slawomir

Martin Honnen pisze:

> Where are 01.xml and 02.xml stored, are they in the same directory as
> the main.xml and the trans.xsl?
>
Yes, all files are stored in the same directory. I assume the problem is
not path or files, but mechanism used to transform files. When I do it
programatically thorough XmlTransfrom class it works fine. In
XmlDataSource some other mechanism must be used. Unfortunately in
production environment I can't use this method to merge files because I
have no information when xml files are changed.