XmlDataSource problem with transformation

S

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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?xml version='1.0' encoding="UTF-8"?>
<groups>
<groupRef href="01.xml"/>
<groupRef href="02.xml"/>
</groups>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

trans.xsl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<groups>
<xsl:apply-templates select="//groupRef"/>
</groups>
</xsl:template>

<xsl:template match="groupRef">
<xsl:copy-of select="document(@href)//group"/>
</xsl:template>

</xsl:stylesheet>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

01.xml
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?xml version='1.0' encoding="UTF-8"?>
<group name="hr" url="http://www.onet.pl" title="Onet.pl" desc="Portal
informacyjny Onet.pl">
<site url="http://nauka.onet.pl" title="Nauka" desc="nauka.onet.pl"/>
<site url="http://news.onet.pl" title="Aktualnsci"
desc="news.onet.pl"/>
<site url="http://film.onet.pl" title="Film" desc="film.onet.pl"/>
</group>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

02.xml
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?xml version='1.0' encoding="UTF-8"?>
<group name="my" url="http://www.wp.pl" title="Wirtualna Polska"
desc="Portal informacyjny Wirtualna Polska">
<site url="http://nauka.wp.pl" title="Nauka" desc="nauka.onet.pl"/>
<site url="http://news.wp.pl" title="Aktualnosci" desc="news.onet.pl"/>
<site url="http://film.wp.pl" title="Film" desc="film.onet.pl"/>
</group>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<asp:XmlDataSource ID="XmlDataSource2" runat="server"
DataFile="~/test2/main.xml"
EnableViewState="False"
XPath="/*/*" TransformFile="~/test2/trans.xsl">
</asp:XmlDataSource>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


Kind Regards,
Slawomir
 
M

Martin Honnen

Slawomir said:
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?
 
S

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top