473,398 Members | 2,404 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,398 software developers and data experts.

Display XML in WebBrowser Control

I am trying to display XML in a WebBrowser Control. I receive a data feed of
XML and am trying to inject it into the control. I have not been successful
in doing so.

The only solution I have found is to write it to a temp file and then use
the Navigate method to load it. As the control is capable of loading it from
disk, I would like to find a way to skip the save/load and just inject.

Thanks,
Dave
Sep 27 '06 #1
11 8683


Webbert wrote:
I am trying to display XML in a WebBrowser Control. I receive a data feed of
XML and am trying to inject it into the control. I have not been successful
in doing so.

The only solution I have found is to write it to a temp file and then use
the Navigate method to load it. As the control is capable of loading it from
disk, I would like to find a way to skip the save/load and just inject.
What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document
in an IE browser window? That is done with an XSL stylesheet that IE
applies using MSXML. Unfortunately I don't think it is possible to get
IE or the WebBrowser control to do that if you have a string with
markup. What you could do in a .NET 2.0 application however is to run
the XSLT transformation with .NET to transform the XML to HTML and then
set the DocumentText property of the control.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 27 '06 #2
The collapsable is nice but not required.

You said..."run the XSLT transformation with .NET to transform the XML to
HTML".
What would I used to do the transformation? Does a generic XSL exist? As
the data I am working on is not known, I can't very well create a specific
XSL.

Thanks,
Dave
"Martin Honnen" wrote:
>

Webbert wrote:
I am trying to display XML in a WebBrowser Control. I receive a data feed of
XML and am trying to inject it into the control. I have not been successful
in doing so.

The only solution I have found is to write it to a temp file and then use
the Navigate method to load it. As the control is capable of loading it from
disk, I would like to find a way to skip the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document
in an IE browser window? That is done with an XSL stylesheet that IE
applies using MSXML. Unfortunately I don't think it is possible to get
IE or the WebBrowser control to do that if you have a string with
markup. What you could do in a .NET 2.0 application however is to run
the XSLT transformation with .NET to transform the XML to HTML and then
set the DocumentText property of the control.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 27 '06 #3
Unfortunately I don't think it is possible to get IE or the WebBrowser
control to do that if you have a string with markup.
Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...
>

Webbert wrote:
>I am trying to display XML in a WebBrowser Control. I receive a data
feed of XML and am trying to inject it into the control. I have not been
successful in doing so. The only solution I have found is to write it to
a temp file and then use the Navigate method to load it. As the control
is capable of loading it from disk, I would like to find a way to skip
the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document in
an IE browser window? That is done with an XSL stylesheet that IE applies
using MSXML. Unfortunately I don't think it is possible to get IE or the
WebBrowser control to do that if you have a string with markup. What you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set the
DocumentText property of the control.

--

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

Sep 28 '06 #4


Dimitre Novatchev wrote:
>>Unfortunately I don't think it is possible to get IE or the WebBrowser
control to do that if you have a string with markup.


Proven possible -- see the code of the XPath Visualizer for details.
Well if you use a stylesheet to transform the XML markup to HTML and
then have IE render that HTML (e.g. by document.writing it with script)
then it is possible. That is why I told the original poster that he can
of course get the display he wants with the web browser control if he
first transforms to HTML and has the web browser control display the HTML.
But what the original poster is after is simply passing on a string with
XML to the web browser control and have the web browser conrol
automatically apply its stylesheet for XML tree pretty printing. The
original poster is loading from disk to achieve that in which case he
does not need to run any transformation itself or need to use script to
document.write something.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 28 '06 #5
Dimitre,

I pulled down the Visualizer and experienced some problems. As a note to the
Readme, you might want to include that if you are experiencing issues with
XML files other than the ones that you provide, that they should check the
property of your files. If any of the files say "unblock" then they should.
This will fix the problem. Took me a while to figure this out.

On to the question...
If I load your Authors.xml and myDefaultss80.xml file into XML Spy and try
to transform, I get an error on
Line 323: <xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">
Invalid prefixError in XPath expression, Invalid prefix

If I try to transform using .NET and the following code

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\myDefaultss80.xsl" );
xslt.Transform( @"..\..\input.xml", @"..\..\authors.xml" );

an Exception is thrown, "Prefix 'xmlns' is not defined."

Any thoughts are appreciated.

Thanks,
Dave
"Dimitre Novatchev" wrote:
Unfortunately I don't think it is possible to get IE or the WebBrowser
control to do that if you have a string with markup.

Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...


Webbert wrote:
I am trying to display XML in a WebBrowser Control. I receive a data
feed of XML and am trying to inject it into the control. I have not been
successful in doing so. The only solution I have found is to write it to
a temp file and then use the Navigate method to load it. As the control
is capable of loading it from disk, I would like to find a way to skip
the save/load and just inject.
What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document in
an IE browser window? That is done with an XSL stylesheet that IE applies
using MSXML. Unfortunately I don't think it is possible to get IE or the
WebBrowser control to do that if you have a string with markup. What you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set the
DocumentText property of the control.

--

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


Sep 28 '06 #6
Dave,
Thank you for the observed problem.

The fact is that this stylesheet was converted from the original non-XSLT
stylesheet used by IE.

It is very old and is accepted by MSXML3 (used by IE) and MSXML4.

The necessary corrections are:

1.

In
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">

remove all "attributes" after the first:

<xsl:template match="@*">
2. For all <xsl-apply-templates(there are 5-6 such) with a select
attribute that contains similar "ayttributes:, remove them.
One could use the stylesheet of the XPath Visualizer for Mozilla, which does
not contain such expressions.

Cheers,
Dimitre Novatchev

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:30**********************************@microsof t.com...
Dimitre,

I pulled down the Visualizer and experienced some problems. As a note to
the
Readme, you might want to include that if you are experiencing issues with
XML files other than the ones that you provide, that they should check the
property of your files. If any of the files say "unblock" then they
should.
This will fix the problem. Took me a while to figure this out.

On to the question...
If I load your Authors.xml and myDefaultss80.xml file into XML Spy and try
to transform, I get an error on
Line 323: <xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">
Invalid prefixError in XPath expression, Invalid prefix

If I try to transform using .NET and the following code

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\myDefaultss80.xsl" );
xslt.Transform( @"..\..\input.xml", @"..\..\authors.xml" );

an Exception is thrown, "Prefix 'xmlns' is not defined."

Any thoughts are appreciated.

Thanks,
Dave
"Dimitre Novatchev" wrote:
Unfortunately I don't think it is possible to get IE or the WebBrowser
control to do that if you have a string with markup.

Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...
>

Webbert wrote:

I am trying to display XML in a WebBrowser Control. I receive a data
feed of XML and am trying to inject it into the control. I have not
been
successful in doing so. The only solution I have found is to write it
to
a temp file and then use the Navigate method to load it. As the
control
is capable of loading it from disk, I would like to find a way to skip
the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document
in
an IE browser window? That is done with an XSL stylesheet that IE
applies
using MSXML. Unfortunately I don't think it is possible to get IE or
the
WebBrowser control to do that if you have a string with markup. What
you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set the
DocumentText property of the control.

--

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



Sep 29 '06 #7
But what the original poster is after is simply passing on a string with
XML to the web browser control and have the web browser conrol
automatically apply its stylesheet for XML tree pretty printing. The
original poster is loading from disk to achieve that in which case he does
not need to run any transformation itself or need to use script to
document.write something.
He didn't say so in his original message -- only that he wanted to avoid
writing to a disk file.

Of course, he has to parse the string containing the xml document and to
perform an xslt transformation then feed the HTML result to the browser
control.
Cheers,
Dimitre Novatchev

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:um**************@TK2MSFTNGP06.phx.gbl...
>

Dimitre Novatchev wrote:
>>>Unfortunately I don't think it is possible to get IE or the WebBrowser
control to do that if you have a string with markup.


Proven possible -- see the code of the XPath Visualizer for details.

Well if you use a stylesheet to transform the XML markup to HTML and then
have IE render that HTML (e.g. by document.writing it with script) then it
is possible. That is why I told the original poster that he can of course
get the display he wants with the web browser control if he first
transforms to HTML and has the web browser control display the HTML.
But what the original poster is after is simply passing on a string with
XML to the web browser control and have the web browser conrol
automatically apply its stylesheet for XML tree pretty printing. The
original poster is loading from disk to achieve that in which case he does
not need to run any transformation itself or need to use script to
document.write something.
--

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

Sep 29 '06 #8
I change the match from
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*" <!--
xml:space="preserve" -->
to
<xsl:template match="@*" <!-- xml:space="preserve" -->

and similar xsl:apply-templates from
<xsl:apply-templates select="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*"/>
<SPAN class="m">></SPAN></DIV>
to
<xsl:apply-templates select="@*"/<SPAN class="m">></SPAN></DIV>
I added enable scripting for the transformer as well do to an execption
being generated.
XsltSettings xsltSettings = new XsltSettings( true, true );

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\Template\myDefaultss80.xsl", xsltSettings, null );
xslt.Transform( @"..\..\Data\authors.xml", @"..\..\Data\output.html" );

and I get an exception in this code
<msxsl:script implements-prefix="vxpathuser">
<![CDATA[
function xml(node)
{
return node(0).xml; //now();
}
An exception of type 'Microsoft.JScript.JScriptException' occurred in
Microsoft.JScript.dll but was not handled in user code. Additional
information: Error in the application.

JScriptException
----------------
Function expected
If I comment out the return statement everything works although I get no
data for the node

<authors xmlns:user="mynamespace">
<author>
<name idd="VH"></name>
<user2:name idd="VH"></user2:name>
<nationality></nationality>
</author>
If I remove all instances of vxpathuser:xml() from the following
<SPAN id="Selected" class="se"<xsl:value-of
select="vxpathuser:xml(.)"/></SPAN>
to
<SPAN id="Selected" class="se"<xsl:value-of select="."/></SPAN>

I get all the data but extra blank lines in the output.

I have been unable to find any information on vxpathuser:xml().
I would imagine that the problem I am experiencing has something to do with
my machine, but am unsure.
Machine Information
==========================
Windows XP SP2
MS IE v6.0.2900.2180.xpsp_sp2_gdr.050301-1519
MSXML 6.0 Parser v6.00.3883.8

Any thoughts are appreciated.
Dave

=================================
"Dimitre Novatchev" wrote:
Dave,
Thank you for the observed problem.

The fact is that this stylesheet was converted from the original non-XSLT
stylesheet used by IE.

It is very old and is accepted by MSXML3 (used by IE) and MSXML4.

The necessary corrections are:

1.

In
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">

remove all "attributes" after the first:

<xsl:template match="@*">
2. For all <xsl-apply-templates(there are 5-6 such) with a select
attribute that contains similar "ayttributes:, remove them.
One could use the stylesheet of the XPath Visualizer for Mozilla, which does
not contain such expressions.

Cheers,
Dimitre Novatchev

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:30**********************************@microsof t.com...
Dimitre,

I pulled down the Visualizer and experienced some problems. As a note to
the
Readme, you might want to include that if you are experiencing issues with
XML files other than the ones that you provide, that they should check the
property of your files. If any of the files say "unblock" then they
should.
This will fix the problem. Took me a while to figure this out.

On to the question...
If I load your Authors.xml and myDefaultss80.xml file into XML Spy and try
to transform, I get an error on
Line 323: <xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">
Invalid prefixError in XPath expression, Invalid prefix

If I try to transform using .NET and the following code

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\myDefaultss80.xsl" );
xslt.Transform( @"..\..\input.xml", @"..\..\authors.xml" );

an Exception is thrown, "Prefix 'xmlns' is not defined."

Any thoughts are appreciated.

Thanks,
Dave
"Dimitre Novatchev" wrote:
Unfortunately I don't think it is possible to get IE or the WebBrowser
control to do that if you have a string with markup.

Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...
Webbert wrote:

I am trying to display XML in a WebBrowser Control. I receive a data
feed of XML and am trying to inject it into the control. I have not
been
successful in doing so. The only solution I have found is to write it
to
a temp file and then use the Navigate method to load it. As the
control
is capable of loading it from disk, I would like to find a way to skip
the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible pretty
print of the XML source tree that you get when you load an XML document
in
an IE browser window? That is done with an XSL stylesheet that IE
applies
using MSXML. Unfortunately I don't think it is possible to get IE or
the
WebBrowser control to do that if you have a string with markup. What
you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set the
DocumentText property of the control.

--

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


Sep 29 '06 #9
I see you want to transform this using .NET XslCompiledTransform

Please, provide an email address and I will send to you one of the newer
(and yet unpublished as part of XPath Visualizer) versions of this
stylesheet. I could post it here, but it is rather long and may not be of
interest to other people.

Cheers,
Dimitre Novatchev.

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:2C**********************************@microsof t.com...
>I change the match from
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*" <!--
xml:space="preserve" -->
to
<xsl:template match="@*" <!-- xml:space="preserve" -->

and similar xsl:apply-templates from
<xsl:apply-templates select="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*"/>
<SPAN class="m">></SPAN></DIV>
to
<xsl:apply-templates select="@*"/<SPAN class="m">></SPAN></DIV>
I added enable scripting for the transformer as well do to an execption
being generated.
XsltSettings xsltSettings = new XsltSettings( true, true );

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\Template\myDefaultss80.xsl", xsltSettings, null );
xslt.Transform( @"..\..\Data\authors.xml", @"..\..\Data\output.html" );

and I get an exception in this code
<msxsl:script implements-prefix="vxpathuser">
<![CDATA[
function xml(node)
{
return node(0).xml; //now();
}
An exception of type 'Microsoft.JScript.JScriptException' occurred in
Microsoft.JScript.dll but was not handled in user code. Additional
information: Error in the application.

JScriptException
----------------
Function expected
If I comment out the return statement everything works although I get no
data for the node

<authors xmlns:user="mynamespace">
<author>
<name idd="VH"></name>
<user2:name idd="VH"></user2:name>
<nationality></nationality>
</author>
If I remove all instances of vxpathuser:xml() from the following
<SPAN id="Selected" class="se"<xsl:value-of
select="vxpathuser:xml(.)"/></SPAN>
to
<SPAN id="Selected" class="se"<xsl:value-of select="."/></SPAN>

I get all the data but extra blank lines in the output.

I have been unable to find any information on vxpathuser:xml().
I would imagine that the problem I am experiencing has something to do
with
my machine, but am unsure.
Machine Information
==========================
Windows XP SP2
MS IE v6.0.2900.2180.xpsp_sp2_gdr.050301-1519
MSXML 6.0 Parser v6.00.3883.8

Any thoughts are appreciated.
Dave

=================================
"Dimitre Novatchev" wrote:
>Dave,
Thank you for the observed problem.

The fact is that this stylesheet was converted from the original non-XSLT
stylesheet used by IE.

It is very old and is accepted by MSXML3 (used by IE) and MSXML4.

The necessary corrections are:

1.

In
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">

remove all "attributes" after the first:

<xsl:template match="@*">
2. For all <xsl-apply-templates(there are 5-6 such) with a select
attribute that contains similar "ayttributes:, remove them.
One could use the stylesheet of the XPath Visualizer for Mozilla, which
does
not contain such expressions.

Cheers,
Dimitre Novatchev

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:30**********************************@microso ft.com...
Dimitre,

I pulled down the Visualizer and experienced some problems. As a note
to
the
Readme, you might want to include that if you are experiencing issues
with
XML files other than the ones that you provide, that they should check
the
property of your files. If any of the files say "unblock" then they
should.
This will fix the problem. Took me a while to figure this out.

On to the question...
If I load your Authors.xml and myDefaultss80.xml file into XML Spy and
try
to transform, I get an error on
Line 323: <xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">
Invalid prefixError in XPath expression, Invalid prefix

If I try to transform using .NET and the following code

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\myDefaultss80.xsl" );
xslt.Transform( @"..\..\input.xml", @"..\..\authors.xml" );

an Exception is thrown, "Prefix 'xmlns' is not defined."

Any thoughts are appreciated.

Thanks,
Dave
"Dimitre Novatchev" wrote:

Unfortunately I don't think it is possible to get IE or the
WebBrowser
control to do that if you have a string with markup.

Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...
Webbert wrote:

I am trying to display XML in a WebBrowser Control. I receive a
data
feed of XML and am trying to inject it into the control. I have
not
been
successful in doing so. The only solution I have found is to write
it
to
a temp file and then use the Navigate method to load it. As the
control
is capable of loading it from disk, I would like to find a way to
skip
the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible
pretty
print of the XML source tree that you get when you load an XML
document
in
an IE browser window? That is done with an XSL stylesheet that IE
applies
using MSXML. Unfortunately I don't think it is possible to get IE or
the
WebBrowser control to do that if you have a string with markup. What
you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set
the
DocumentText property of the control.

--

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



Sep 29 '06 #10
we**************@hotmail.com.REMOVE.THIS

"Dimitre Novatchev" wrote:
I see you want to transform this using .NET XslCompiledTransform

Please, provide an email address and I will send to you one of the newer
(and yet unpublished as part of XPath Visualizer) versions of this
stylesheet. I could post it here, but it is rather long and may not be of
interest to other people.

Cheers,
Dimitre Novatchev.

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:2C**********************************@microsof t.com...
I change the match from
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*" <!--
xml:space="preserve" -->
to
<xsl:template match="@*" <!-- xml:space="preserve" -->

and similar xsl:apply-templates from
<xsl:apply-templates select="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*"/>
<SPAN class="m">></SPAN></DIV>
to
<xsl:apply-templates select="@*"/<SPAN class="m">></SPAN></DIV>
I added enable scripting for the transformer as well do to an execption
being generated.
XsltSettings xsltSettings = new XsltSettings( true, true );

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\Template\myDefaultss80.xsl", xsltSettings, null );
xslt.Transform( @"..\..\Data\authors.xml", @"..\..\Data\output.html" );

and I get an exception in this code
<msxsl:script implements-prefix="vxpathuser">
<![CDATA[
function xml(node)
{
return node(0).xml; //now();
}
An exception of type 'Microsoft.JScript.JScriptException' occurred in
Microsoft.JScript.dll but was not handled in user code. Additional
information: Error in the application.

JScriptException
----------------
Function expected
If I comment out the return statement everything works although I get no
data for the node

<authors xmlns:user="mynamespace">
<author>
<name idd="VH"></name>
<user2:name idd="VH"></user2:name>
<nationality></nationality>
</author>
If I remove all instances of vxpathuser:xml() from the following
<SPAN id="Selected" class="se"<xsl:value-of
select="vxpathuser:xml(.)"/></SPAN>
to
<SPAN id="Selected" class="se"<xsl:value-of select="."/></SPAN>

I get all the data but extra blank lines in the output.

I have been unable to find any information on vxpathuser:xml().
I would imagine that the problem I am experiencing has something to do
with
my machine, but am unsure.
Machine Information
==========================
Windows XP SP2
MS IE v6.0.2900.2180.xpsp_sp2_gdr.050301-1519
MSXML 6.0 Parser v6.00.3883.8

Any thoughts are appreciated.
Dave

=================================
"Dimitre Novatchev" wrote:
Dave,
Thank you for the observed problem.

The fact is that this stylesheet was converted from the original non-XSLT
stylesheet used by IE.

It is very old and is accepted by MSXML3 (used by IE) and MSXML4.

The necessary corrections are:

1.

In
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">

remove all "attributes" after the first:

<xsl:template match="@*">
2. For all <xsl-apply-templates(there are 5-6 such) with a select
attribute that contains similar "ayttributes:, remove them.
One could use the stylesheet of the XPath Visualizer for Mozilla, which
does
not contain such expressions.

Cheers,
Dimitre Novatchev

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:30**********************************@microsof t.com...
Dimitre,

I pulled down the Visualizer and experienced some problems. As a note
to
the
Readme, you might want to include that if you are experiencing issues
with
XML files other than the ones that you provide, that they should check
the
property of your files. If any of the files say "unblock" then they
should.
This will fix the problem. Took me a while to figure this out.

On to the question...
If I load your Authors.xml and myDefaultss80.xml file into XML Spy and
try
to transform, I get an error on
Line 323: <xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">
Invalid prefixError in XPath expression, Invalid prefix

If I try to transform using .NET and the following code

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\myDefaultss80.xsl" );
xslt.Transform( @"..\..\input.xml", @"..\..\authors.xml" );

an Exception is thrown, "Prefix 'xmlns' is not defined."

Any thoughts are appreciated.

Thanks,
Dave
"Dimitre Novatchev" wrote:

Unfortunately I don't think it is possible to get IE or the
WebBrowser
control to do that if you have a string with markup.

Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...
Webbert wrote:

I am trying to display XML in a WebBrowser Control. I receive a
data
feed of XML and am trying to inject it into the control. I have
not
been
successful in doing so. The only solution I have found is to write
it
to
a temp file and then use the Navigate method to load it. As the
control
is capable of loading it from disk, I would like to find a way to
skip
the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible
pretty
print of the XML source tree that you get when you load an XML
document
in
an IE browser window? That is done with an XSL stylesheet that IE
applies
using MSXML. Unfortunately I don't think it is possible to get IE or
the
WebBrowser control to do that if you have a string with markup. What
you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set
the
DocumentText property of the control.

--

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



Sep 29 '06 #11
Works great.
Much appreciated.

Cheers,
Dave
"Dimitre Novatchev" wrote:
I see you want to transform this using .NET XslCompiledTransform

Please, provide an email address and I will send to you one of the newer
(and yet unpublished as part of XPath Visualizer) versions of this
stylesheet. I could post it here, but it is rather long and may not be of
interest to other people.

Cheers,
Dimitre Novatchev.

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:2C**********************************@microsof t.com...
I change the match from
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*" <!--
xml:space="preserve" -->
to
<xsl:template match="@*" <!-- xml:space="preserve" -->

and similar xsl:apply-templates from
<xsl:apply-templates select="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*"/>
<SPAN class="m">></SPAN></DIV>
to
<xsl:apply-templates select="@*"/<SPAN class="m">></SPAN></DIV>
I added enable scripting for the transformer as well do to an execption
being generated.
XsltSettings xsltSettings = new XsltSettings( true, true );

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\Template\myDefaultss80.xsl", xsltSettings, null );
xslt.Transform( @"..\..\Data\authors.xml", @"..\..\Data\output.html" );

and I get an exception in this code
<msxsl:script implements-prefix="vxpathuser">
<![CDATA[
function xml(node)
{
return node(0).xml; //now();
}
An exception of type 'Microsoft.JScript.JScriptException' occurred in
Microsoft.JScript.dll but was not handled in user code. Additional
information: Error in the application.

JScriptException
----------------
Function expected
If I comment out the return statement everything works although I get no
data for the node

<authors xmlns:user="mynamespace">
<author>
<name idd="VH"></name>
<user2:name idd="VH"></user2:name>
<nationality></nationality>
</author>
If I remove all instances of vxpathuser:xml() from the following
<SPAN id="Selected" class="se"<xsl:value-of
select="vxpathuser:xml(.)"/></SPAN>
to
<SPAN id="Selected" class="se"<xsl:value-of select="."/></SPAN>

I get all the data but extra blank lines in the output.

I have been unable to find any information on vxpathuser:xml().
I would imagine that the problem I am experiencing has something to do
with
my machine, but am unsure.
Machine Information
==========================
Windows XP SP2
MS IE v6.0.2900.2180.xpsp_sp2_gdr.050301-1519
MSXML 6.0 Parser v6.00.3883.8

Any thoughts are appreciated.
Dave

=================================
"Dimitre Novatchev" wrote:
Dave,
Thank you for the observed problem.

The fact is that this stylesheet was converted from the original non-XSLT
stylesheet used by IE.

It is very old and is accepted by MSXML3 (used by IE) and MSXML4.

The necessary corrections are:

1.

In
<xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">

remove all "attributes" after the first:

<xsl:template match="@*">
2. For all <xsl-apply-templates(there are 5-6 such) with a select
attribute that contains similar "ayttributes:, remove them.
One could use the stylesheet of the XPath Visualizer for Mozilla, which
does
not contain such expressions.

Cheers,
Dimitre Novatchev

"Webbert" <we**************@hotmail.com.REMOVE.THISwrote in message
news:30**********************************@microsof t.com...
Dimitre,

I pulled down the Visualizer and experienced some problems. As a note
to
the
Readme, you might want to include that if you are experiencing issues
with
XML files other than the ones that you provide, that they should check
the
property of your files. If any of the files say "unblock" then they
should.
This will fix the problem. Took me a while to figure this out.

On to the question...
If I load your Authors.xml and myDefaultss80.xml file into XML Spy and
try
to transform, I get an error on
Line 323: <xsl:template match="@*|@xmlns:*|@xmlns|@xml:*|@dt:*|@d2:*">
Invalid prefixError in XPath expression, Invalid prefix

If I try to transform using .NET and the following code

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load( @"..\..\myDefaultss80.xsl" );
xslt.Transform( @"..\..\input.xml", @"..\..\authors.xml" );

an Exception is thrown, "Prefix 'xmlns' is not defined."

Any thoughts are appreciated.

Thanks,
Dave
"Dimitre Novatchev" wrote:

Unfortunately I don't think it is possible to get IE or the
WebBrowser
control to do that if you have a string with markup.

Proven possible -- see the code of the XPath Visualizer for details.

Another remark: defaultss.xsl is not written in XSLT, as we well know.

Cheers,
Dimitre Novatchev
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eN*************@TK2MSFTNGP06.phx.gbl...
Webbert wrote:

I am trying to display XML in a WebBrowser Control. I receive a
data
feed of XML and am trying to inject it into the control. I have
not
been
successful in doing so. The only solution I have found is to write
it
to
a temp file and then use the Navigate method to load it. As the
control
is capable of loading it from disk, I would like to find a way to
skip
the save/load and just inject.

What kind of "XML display" are you looking for? That collapsible
pretty
print of the XML source tree that you get when you load an XML
document
in
an IE browser window? That is done with an XSL stylesheet that IE
applies
using MSXML. Unfortunately I don't think it is possible to get IE or
the
WebBrowser control to do that if you have a string with markup. What
you
could do in a .NET 2.0 application however is to run the XSLT
transformation with .NET to transform the XML to HTML and then set
the
DocumentText property of the control.

--

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



Oct 9 '06 #12

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

Similar topics

0
by: ThisIsAMess | last post by:
Hello! Say, I am using a Webbrowser control in a VB6 application to display 'outside' imported data-filled charts. I want to use the mouse to 'draw' a line from two different points on the chart...
9
by: ASP .NET Newbie | last post by:
How can I run a WebBrowser control using ASP.NET/VB.NET? I know I can use the WebClient to get the page data, but I need to be able to use the WebBrowser (AxWebBrowser)? Thanks, Chad
10
by: Selden McCabe | last post by:
I'm trying to display some HTML on a form in a VB.Net project. I've referenced the COM WebBrowser control, and put an instance of it on my form. But during the Form_Load, I'm getting the...
0
by: gene kelley | last post by:
I have a WindowForms app that has a WebBrowser control which works as expected except for navigating to sites that require user/password. In IE, a given URL in this catagory returns the IE login...
1
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get...
1
by: David Veeneman | last post by:
I'm writing an application that will manage a database of documents typed into the application by the user. Some documents will contain links to other documents. If the user clicks on a link, the...
2
by: Scott Gravenhorst | last post by:
I recently (within 30 days) downloaded and installed VB 2005 Express. I like it a whole lot... but: I have been trying to work with the WebBrowser control to display a small amount of help text...
4
by: David | last post by:
I'm using the AxSHDocVw.WebBrowser control to download data from a webpage at work (it's an internal page on my company's intranet). The page produces a runtime error after a while and the...
0
by: Artie | last post by:
Hi, I'm using a WebBrowser control to display xml formatted to html using a stylesheet. In certain scenarios, if I detect that the xml is invalid, I'd need to display the raw invalid xml in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.