473,320 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

strange and curious problem

Hello and thank you for reading on (hopefully).

How does one typecast the XMLREADER returned from the XSLTRANSFORM
method 'transform' into XMLTEXTREADER, so it can be passed in to an
XMLVALIDATINGREADER?

I am getting an invalid cast.

It seems that although the XSLTRANSFORM 'transform' method does return
a XMLREADER object and you can work with that, you can not pass it
into the XMLVALIDATINGREADER construct to allow validation of the
resultant xml.
Thanks for any commments.

BB.
Nov 12 '05 #1
4 1351


badbetty wrote:

How does one typecast the XMLREADER returned from the XSLTRANSFORM
method 'transform' into XMLTEXTREADER, so it can be passed in to an
XMLVALIDATINGREADER?

I am getting an invalid cast.


When I look at the API documentation then both allow an XmlReader so
simply use that, I am not sure where you need or want to cast:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxslxsltransformclasstransformtopic6. asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlValidatingReaderClassctorTopic1.a sp>
If you still have problems, show us the relevant code snippets so what
we can see what exactly you are trying to cast to what.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Martin Honnen <ma*******@yahoo.de> wrote in message news:<#L**************@tk2msftngp13.phx.gbl>...
badbetty wrote:

How does one typecast the XMLREADER returned from the XSLTRANSFORM
method 'transform' into XMLTEXTREADER, so it can be passed in to an
XMLVALIDATINGREADER?

I am getting an invalid cast.


When I look at the API documentation then both allow an XmlReader so
simply use that, I am not sure where you need or want to cast:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxslxsltransformclasstransformtopic6. asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlValidatingReaderClassctorTopic1.a sp>
If you still have problems, show us the relevant code snippets so what
we can see what exactly you are trying to cast to what.

Thank you for the reply.
Excuse the dirty VB code/syntax/spelling (just to keep it brief and
for example only)

dim xpd as xpathdocument
dim xr as xmlreader
dim xvr as xmlvalidatingreader
dim xsl as xsltransform

xpd = new xpathdocument("http://bla bla")

xsl = new xsltransform()
xsl.load("http://bla bla bla")

xr = xsl.transform(xpd, nothing)

xvr = new xmlvalidatingreader(xr) << this fails !
it seems that xmlvalidatingreader constructor expects xmlreader - but
only as a xmltextreader (in the current dotnet implementation).

so tried to typecast (i used all different ways - this is one) just as
a check, even though it should not be required i agree :

xvr = new xmlvalidatingreader(ctype(xr,xmltextreader)) << this
fails too
anyway, as i was wanting to validate the resultant transfored xml it
looks like i can not do it at present. or have i missed a trick.

thank you.
Nov 12 '05 #3
That's a strange problem, alright. I never went looking for this one
before, but I'm sure it can be done.

I spent a few minutes digging around the framework and no easy solution
popped out.

One idea: Create an XML Document using the reader that results from the XSL
Transform. Then write the document to a memory stream. Then read the
memory stream using an XMLValidatingReader.

Seems kinda round-about. If anyone has a better idea: please step up!

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"badbetty" <bc*@genie.co.uk> wrote in message
news:5d**************************@posting.google.c om...
Martin Honnen <ma*******@yahoo.de> wrote in message
news:<#L**************@tk2msftngp13.phx.gbl>...
badbetty wrote:

> How does one typecast the XMLREADER returned from the XSLTRANSFORM
> method 'transform' into XMLTEXTREADER, so it can be passed in to an
> XMLVALIDATINGREADER?
>
> I am getting an invalid cast.


When I look at the API documentation then both allow an XmlReader so
simply use that, I am not sure where you need or want to cast:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxslxsltransformclasstransformtopic6. asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlValidatingReaderClassctorTopic1.a sp>
If you still have problems, show us the relevant code snippets so what
we can see what exactly you are trying to cast to what.

Thank you for the reply.
Excuse the dirty VB code/syntax/spelling (just to keep it brief and
for example only)

dim xpd as xpathdocument
dim xr as xmlreader
dim xvr as xmlvalidatingreader
dim xsl as xsltransform

xpd = new xpathdocument("http://bla bla")

xsl = new xsltransform()
xsl.load("http://bla bla bla")

xr = xsl.transform(xpd, nothing)

xvr = new xmlvalidatingreader(xr) << this fails !
it seems that xmlvalidatingreader constructor expects xmlreader - but
only as a xmltextreader (in the current dotnet implementation).

so tried to typecast (i used all different ways - this is one) just as
a check, even though it should not be required i agree :

xvr = new xmlvalidatingreader(ctype(xr,xmltextreader)) << this
fails too
anyway, as i was wanting to validate the resultant transfored xml it
looks like i can not do it at present. or have i missed a trick.

thank you.

Nov 12 '05 #4


badbetty wrote:

Excuse the dirty VB code/syntax/spelling (just to keep it brief and
for example only)

dim xpd as xpathdocument
dim xr as xmlreader
dim xvr as xmlvalidatingreader
dim xsl as xsltransform

xpd = new xpathdocument("http://bla bla")

xsl = new xsltransform()
xsl.load("http://bla bla bla")

xr = xsl.transform(xpd, nothing)

xvr = new xmlvalidatingreader(xr) << this fails !
it seems that xmlvalidatingreader constructor expects xmlreader - but
only as a xmltextreader (in the current dotnet implementation).


I see the problem now, looks a bit like a design flaw then, the
Transform method returns an XmlReader by signature and the
XmlValidatingReader takes one by its signature but then in its
documentation says it throws an illegal argument execption if the
argument is not an XmlTextReader and that is what happens. As the
Transform method (at least as tested here with .NET 1.1) returns an
object of type System.Xml.Xsl.ReaderOutput which doesn't allow a cast to
XmlTextReader there is no way then to simply chain the XmlReader result
of a Transform call to an XmlValidatingReader.

It seems you are better off transforming to a stream and consume that
with an XmlTextReader consumed by an XmlValidatingReader e.g. (C#)

MemoryStream xsltOutput = new MemoryStream();
xsltProcessor.Transform(xsltInput, null, xsltOutput);
xsltOutput.Position = 0;

XmlValidatingReader xmlValidator = new XmlValidatingReader(new
XmlTextReader(xsltOutput));

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jason Heyes | last post by:
The following program does not compile. Apparantly "t" is inaccessible. #include <iostream> using namespace std; template <class T> class Foo { T t; public: Foo(T t_) : t(t_) { }
2
by: Gandu | last post by:
Could some C++ guru shed some light as to what might be going on? I have the following two classes which are simply data containers: const unsigned int MAXSIZE = 40; class DataItem{ char...
2
by: James Niceguy | last post by:
Hi, I have written a simple program that does the following: The main program will spown MAX_THREADS number of threads, each of which will simply add to a global shared counter for MAX_COUNT...
14
by: Mario | last post by:
I wrote a tooltips script. I've noticed "small" problem occuring while using the IE browser. If a site is long enough for a scroll to appear and we move the mouse indicator on the link then the...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
2
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions...
10
by: Curious | last post by:
Hi, I have a worker thread running, where basically its operation is to execute in an infinite loop. Now, when I am suspending this thread, the CPU usage time is still remaining 100%. What...
1
by: BG | last post by:
Hey Everyone, Win2K Pro w/all Updates, VB.Net Standard 2003, .NET 1.1 w/all updates I have a web app that I've been working, coding,testing,coding, etc. Works fine - debugger debugs stuff as...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.