.NETGURU
web services and CDATA elements
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngbeta' list.


James Nguyen
Hope someone can shed some light on this as I've been utterly frustrated in
trying to find a solution.. I think I just need some fresh eyes on the
problem as I'm probably myopic to my own code right now.. I'm guessing this
*has* to be something simple I'm overlooking...

First, let me show you a working production example of what I'm talking
about...

http://services.buy.com/Affiliate/BuyAffiliate.asp?SKU(144835

Now, the problem....

Look at the description that is generated...notice the HTML that is being
rendered as regular text? That's bad. I need it to render as regular HTML
tags instead of a bunch of < and > ASCII codes.

Let me walk you through real quick how this element is returned via the
XML...

First, there's a custom class I've built that hits the databases and stuffs
all these values into various public properties..

The case in question is public string Description

This description will often have HTML elements in it, since the database has
HTML stored in it..

knowing this, I set Description on the public property as such:

public string Description {
    get { return "<![CDATA[" + _description + "]]>"; }
}

My thinking was that If I just wrapped the CDATA element, then it'd just get
sent as escaped XML once my class got serialized into XML and sent over the
wire as the web service.

(You can see the XML used in my example site above..there's a link to it)

Now...I realize that I could probably iterate through my XML and selectively
replace the and rebuild and HTML encode my HTML in the description field..
that's fine and dandy.. but the problem I'm trying to solve in the end
relies on XSLT written by "non programmer types"..

In the end, I'd like for them to be able to do a simple XSLT statement like:

<xsl:value-of select&#"D;escription" />

and be returned all the text in the Description tag INCLUDING the properly
formatted HTML.. (too bad XSL doesn't have a HTMLEncode() function &#P ;)

Am I making sense? Can someone help me out before I go screaming mad?
Thanks a lot!

If you want to play with the toy i've built, feel free....it'll work for all
buy.com SKUs EXCEPT comp and soft right now... I goofed and forgot to do
some database stuff and now I've got to go through the paperwork trail to
get my database changes moved forward first.. =P

HELP!

James Nguyen
Senior Software Engineer
buy.com, Inc.
Click here to reveal e-mail address
(949) 389-2320
c: (714) 394-8641
Reply to this message...
 
    
James Nguyen
Hope someone can shed some light on this as I've been utterly frustrated in
trying to find a solution.. I think I just need some fresh eyes on the
problem as I'm probably myopic to my own code right now.. I'm guessing this
*has* to be something simple I'm overlooking...

First, let me show you a working production example of what I'm talking
about...

http://services.buy.com/Affiliate/BuyAffiliate.asp?SKU&#40;144835

Now, the problem....

Look at the description that is generated...notice the HTML that is being
rendered as regular text? That's bad. I need it to render as regular HTML
tags instead of a bunch of < and > ASCII codes.

Let me walk you through real quick how this element is returned via the
XML...

First, there's a custom class I've built that hits the databases and stuffs
all these values into various public properties..

The case in question is public string Description

This description will often have HTML elements in it, since the database has
HTML stored in it..

knowing this, I set Description on the public property as such:

public string Description {
    get { return "<![CDATA[" + _description + "]]>"; }
}

My thinking was that If I just wrapped the CDATA element, then it'd just get
sent as escaped XML once my class got serialized into XML and sent over the
wire as the web service.

(You can see the XML used in my example site above..there's a link to it)

Now...I realize that I could probably iterate through my XML and selectively
replace the and rebuild and HTML encode my HTML in the description field..
that's fine and dandy.. but the problem I'm trying to solve in the end
relies on XSLT written by "non programmer types"..

In the end, I'd like for them to be able to do a simple XSLT statement like:

<xsl:value-of select&#"D;escription" />

and be returned all the text in the Description tag INCLUDING the properly
formatted HTML.. (too bad XSL doesn't have a HTMLEncode() function &#P ;)

Am I making sense? Can someone help me out before I go screaming mad?
Thanks a lot!

If you want to play with the toy i've built, feel free....it'll work for all
buy.com SKUs EXCEPT comp and soft right now... I goofed and forgot to do
some database stuff and now I've got to go through the paperwork trail to
get my database changes moved forward first.. =P

HELP!

James Nguyen
Senior Software Engineer
buy.com, Inc.
Click here to reveal e-mail address
(949) 389-2320
c: (714) 394-8641
Reply to this message...
 
    
Stuart C. Salsbury
I think the xhtml fragement in the _document field/property is already
output-escaped (full of < and such where it shouldn't be), in which case
wrapping it in CDATA will not help.

I've found that beta1 xsl transforms leave some things to be desired with
regards to the <xsl:output/> method, namely (for one) that they don't seem
to pay any attention to the disable-output-escaping attribute (
http://www.w3.org/TR/xslt#disable-output-escaping ), such that you end up
with lots of <'s etc. in your xhtml (quite crippling to one's
objectives!)

Is your stuff going through a .net XslTransform.Transform method? If so,
this may be the problem. In which case, your best alternative until this is
fixed is probably to use msxml3, which is much sterner stuff as regards
conformance. You can call msxml3 easily once you wrap it for the CLR.

If you aren't using .net nor outdated msxml to do xsl transforms, then more
code (specifically the source that sets the _document property/field would
probably help to clarify, as that seems to be where the problem lies.

Regards,
Stuart Salsbury
Ernst & Young LLP

-----Original Message-----
From: James Nguyen [mailto:Click here to reveal e-mail address]
Sent: Wednesday, May 09, 2001 2:45 PM
To: aspngbeta
Subject: [aspngbeta] web services and CDATA elements

Hope someone can shed some light on this as I've been utterly frustrated in
trying to find a solution.. I think I just need some fresh eyes on the
problem as I'm probably myopic to my own code right now.. I'm guessing this
*has* to be something simple I'm overlooking...
First, let me show you a working production example of what I'm talking
about...
http://services.buy.com/Affiliate/BuyAffiliate.asp?SKU&#40;144835
Now, the problem....
Look at the description that is generated...notice the HTML that is being
rendered as regular text? That's bad. I need it to render as regular HTML
tags instead of a bunch of < and > ASCII codes.
Let me walk you through real quick how this element is returned via the
XML...
First, there's a custom class I've built that hits the databases and stuffs
all these values into various public properties..
The case in question is public string Description
This description will often have HTML elements in it, since the database has
HTML stored in it..
knowing this, I set Description on the public property as such:
public string Description {
get { return "<![CDATA[" + _description + "]]>"; }
}
My thinking was that If I just wrapped the CDATA element, then it'd just get
sent as escaped XML once my class got serialized into XML and sent over the
wire as the web service.
(You can see the XML used in my example site above..there's a link to it)
Now...I realize that I could probably iterate through my XML and selectively
replace the and rebuild and HTML encode my HTML in the description field..
that's fine and dandy.. but the problem I'm trying to solve in the end
relies on XSLT written by "non programmer types"..
In the end, I'd like for them to be able to do a simple XSLT statement like:
<xsl:value-of select&#"D;escription" />
and be returned all the text in the Description tag INCLUDING the properly
formatted HTML.. (too bad XSL doesn't have a HTMLEncode() function &#P ;)
Am I making sense? Can someone help me out before I go screaming mad?
Thanks a lot!
If you want to play with the toy i've built, feel free....it'll work for all
buy.com SKUs EXCEPT comp and soft right now... I goofed and forgot to do
some database stuff and now I've got to go through the paperwork trail to
get my database changes moved forward first.. =P
HELP!
James Nguyen
Senior Software Engineer
buy.com, Inc.
Click here to reveal e-mail address
(949) 389-2320
c: (714) 394-8641
| [aspngbeta] member Click here to reveal e-mail address &# Y;OUR ID |
http://www.asplists.com/asplists/aspngbeta.asp &# J;OIN/QUIT
Reply to this message...
 
    
James Nguyen
In the example sent, I actually wrote a plain jane ASP page that consumes
the web services using MSXML... (MSXML 4 beta to be exact). Doing various
traces it seems that the conversion of my tags to > and < doesn't
happen until the transformation occurs using TransformNode()... The link
you sent seems to be interesting, so I'll look up that venue..

I just wish that I could conclusively decide when my problem occurs since
that would make trying to solve the problem a much more focused attempt..
i.e. is my .NET code? Is simply wrapping the CDATA element as a string not
sufficient for the XML retunred by the web service to recognize that I'm
dealing w/ an XML block that needs to be escaped? Is it the consumption of
it all on the regular ASP side? Is it the transform I run?

bah..

James
-----Original Message-----
From: Stuart C. Salsbury [mailto:Click here to reveal e-mail address]
Sent: Wednesday, May 09, 2001 11:35 PM
To: aspngbeta
Subject: [aspngbeta] RE: web services and CDATA elements

I think the xhtml fragement in the _document field/property is already
output-escaped (full of < and such where it shouldn't be), in which case
wrapping it in CDATA will not help.

I've found that beta1 xsl transforms leave some things to be desired with
regards to the <xsl:output/> method, namely (for one) that they don't seem
to pay any attention to the disable-output-escaping attribute (
http://www.w3.org/TR/xslt#disable-output-escaping
<http://www.w3.org/TR/xslt#disable-output-escaping> ), such that you end up
with lots of <'s etc. in your xhtml (quite crippling to one's
objectives!)

Is your stuff going through a .net XslTransform.Transform method? If so,
this may be the problem. In which case, your best alternative until this is
fixed is probably to use msxml3, which is much sterner stuff as regards
conformance. You can call msxml3 easily once you wrap it for the CLR.

If you aren't using .net nor outdated msxml to do xsl transforms, then more
code (specifically the source that sets the _document property/field would
probably help to clarify, as that seems to be where the problem lies.

Regards,
Stuart Salsbury
Ernst & Young LLP
Reply to this message...
 
    
Croft Daniel 6231 DCROFT
Hi James,

I am doing the same thing using MSXML3, I have no problem with the escaping
(i.e. I get non-escaped <'s and &'s etc.) the transform had very little do
do with this (in the sense that it happens based on the XSLT not the
transform method), it's the XSLT file. Please see below for XSLT snippets. I
don't disable output escaping with the output tag I use the
disable-output-escaping attribute of the <xsl:value-of> tag.

Daniel

&#==;&#=H;eader&#==;&#==;&#==;&#==;&#==;&#==;<?xml version&#"1;.0" ?>

<xsl:stylesheet xmlns:xsl&#"h;ttp://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform> " version&#"1;.0">

<xsl:output method&#"h;tml" version&#"4;.0" encoding&#"I;SO-8859-1" />
&#==;&#=P;art of a template&#==;&#==;&#==;=<xsl:value-of select&#"o;bjectvalue" disable-output-escaping&#"y;es" />
&#==;&#==;&#==;&#==;&#==;&#==;&#==;&#==;&#==;=-----Original Message-----
From: James Nguyen [mailto:Click here to reveal e-mail address]
Sent: Friday, 11 May 2001 2:59 AM
To: aspngbeta
Subject: [aspngbeta] RE: web services and CDATA elements

In the example sent, I actually wrote a plain jane ASP page that consumes
the web services using MSXML... (MSXML 4 beta to be exact). Doing various
traces it seems that the conversion of my tags to > and < doesn't
happen until the transformation occurs using TransformNode()... The link
you sent seems to be interesting, so I'll look up that venue..

I just wish that I could conclusively decide when my problem occurs since
that would make trying to solve the problem a much more focused attempt..
i.e. is my .NET code? Is simply wrapping the CDATA element as a string not
sufficient for the XML retunred by the web service to recognize that I'm
dealing w/ an XML block that needs to be escaped? Is it the consumption of
it all on the regular ASP side? Is it the transform I run?

bah..

James
-----Original Message-----
From: Stuart C. Salsbury [mailto:Click here to reveal e-mail address]
Sent: Wednesday, May 09, 2001 11:35 PM
To: aspngbeta
Subject: [aspngbeta] RE: web services and CDATA elements

I think the xhtml fragement in the _document field/property is already
output-escaped (full of < and such where it shouldn't be), in which case
wrapping it in CDATA will not help.

I've found that beta1 xsl transforms leave some things to be desired with
regards to the <xsl:output/> method, namely (for one) that they don't seem
to pay any attention to the disable-output-escaping attribute
(http://www.w3.org/TR/xslt#disable-output-escaping
<http://www.w3.org/TR/xslt#disable-output-escaping> ), such that you end up
with lots of <'s etc. in your xhtml (quite crippling to one's
objectives!)

Is your stuff going through a .net XslTransform.Transform method? If so,
this may be the problem. In which case, your best alternative until this is
fixed is probably to use msxml3, which is much sterner stuff as regards
conformance. You can call msxml3 easily once you wrap it for the CLR.

If you aren't using .net nor outdated msxml to do xsl transforms, then more
code (specifically the source that sets the _document property/field would
probably help to clarify, as that seems to be where the problem lies.

Regards,
Stuart Salsbury
Ernst & Young LLP

| [aspngbeta] member Click here to reveal e-mail address &# Y;OUR ID |
http://www.asplists.com/asplists/aspngbeta.asp &# J;OIN/QUIT

NOTICE
If you are not an authorised recipient of this e-mail, please contact Blake Dawson Waldron immediately by return e-mail or by telephone on 61-2-9258-6000.
In this case, you should not read, print, re-transmit, store or act in reliance on this e-mail or any attachments, and should destroy all copies of them.
This e-mail and any attachments are confidential and may contain legally privileged information and/or copyright material of Blake Dawson Waldron or third parties.
You should only re-transmit, distribute or commercialise the material if you are authorised to do so.
Where applicable, liability is limited by the NSW Solicitors' Limitation of Liability Scheme.
This notice should not be removed.
Reply to this message...
 
    
Stuart C. Salsbury
I haven't used msxml4 yet, so I can't speak for it, but I would hope it's
not taking backward steps, and Daniel Croft has just posted that he's having
success with using disable-output-escaping attribute on the <xsl:value-of/>
element (in msxml3), which I would also hope is consistent with the more
overarching instruction of <xsl:output disable-output-escaping&#"y;es" />

I'd repeat my statement that wrapping output-escaped stuff in CDATA isn't
going to help because the < has already been turned into < and it's too
late (unless you explictly replace < with <, which would clearly be
ridiculous.

One thing in your note suggests that perhaps you have the concept backwards.
You wrote, "...I'm dealing w/ an XML block that needs to be escaped..." In
fact, I think you're dealing with an XML block that specifcally needs to not
be escaped. Perhaps a slip of the ethereal tongue, but perhaps a relevant
point. To summarize, make sure you're saying disable-output-escaping&#"y;es",
rather than "no".

Regards,
Stuart Salsbury
Ernst & Young LLP

-----Original Message-----
From: James Nguyen [mailto:Click here to reveal e-mail address]
Sent: Thursday, May 10, 2001 12:59 PM
To: aspngbeta
Subject: [aspngbeta] RE: web services and CDATA elements

In the example sent, I actually wrote a plain jane ASP page that consumes
the web services using MSXML... (MSXML 4 beta to be exact). Doing various
traces it seems that the conversion of my tags to > and < doesn't
happen until the transformation occurs using TransformNode()... The link
you sent seems to be interesting, so I'll look up that venue..

I just wish that I could conclusively decide when my problem occurs since
that would make trying to solve the problem a much more focused attempt..
i.e. is my .NET code? Is simply wrapping the CDATA element as a string not
sufficient for the XML retunred by the web service to recognize that I'm
dealing w/ an XML block that needs to be escaped? Is it the consumption of
it all on the regular ASP side? Is it the transform I run?

bah..

James
-----Original Message-----
From: Stuart C. Salsbury [mailto:Click here to reveal e-mail address]
Sent: Wednesday, May 09, 2001 11:35 PM
To: aspngbeta
Subject: [aspngbeta] RE: web services and CDATA elements
I think the xhtml fragement in the _document field/property is already
output-escaped (full of < and such where it shouldn't be), in which case
wrapping it in CDATA will not help.

I've found that beta1 xsl transforms leave some things to be desired with
regards to the <xsl:output/> method, namely (for one) that they don't seem
to pay any attention to the disable-output-escaping attribute (
http://www.w3.org/TR/xslt#disable-output-escaping ), such that you end up
with lots of <'s etc. in your xhtml (quite crippling to one's
objectives!)

Is your stuff going through a .net XslTransform.Transform method? If so,
this may be the problem. In which case, your best alternative until this is
fixed is probably to use msxml3, which is much sterner stuff as regards
conformance. You can call msxml3 easily once you wrap it for the CLR.

If you aren't using .net nor outdated msxml to do xsl transforms, then more
code (specifically the source that sets the _document property/field would
probably help to clarify, as that seems to be where the problem lies.

Regards,
Stuart Salsbury
Ernst & Young LLP
Reply to this message...
 
    
Nick Alexander
There is another solution in you xslt file include=20
a <xsl:output method=3D"xml"/> this prevents the escaping of the
tags
=20
Nick Alexander
-----Original Message-----
From: James Nguyen [mailto:Click here to reveal e-mail address]
Sent: 10 May 2001 06:59
To: aspngbeta
Subject: [aspngbeta] RE: web services and CDATA elements

In the example sent, I actually wrote a plain jane ASP page that
consumes the web services using MSXML... (MSXML 4 beta to be exact).
Doing various traces it seems that the conversion of my tags to > and
< doesn't happen until the transformation occurs using
TransformNode()... The link you sent seems to be interesting, so I'll
look up that venue.. =20
=20
I just wish that I could conclusively decide when my problem occurs
since that would make trying to solve the problem a much more focused
attempt.. i.e. is my .NET code? Is simply wrapping the CDATA element
as a string not sufficient for the XML retunred by the web service to
recognize that I'm dealing w/ an XML block that needs to be escaped? Is
it the consumption of it all on the regular ASP side? Is it the
transform I run?
=20
bah..
=20
James
-----Original Message-----
From: Stuart C. Salsbury [mailto:Click here to reveal e-mail address]
Sent: Wednesday, May 09, 2001 11:35 PM
To: aspngbeta
Subject: [aspngbeta] RE: web services and CDATA elements

I think the xhtml fragement in the _document field/property is already
output-escaped (full of < and such where it shouldn't be), in which
case wrapping it in CDATA will not help.
=20
I've found that beta1 xsl transforms leave some things to be desired
with regards to the <xsl:output/> method, namely (for one) that they
don't seem to pay any attention to the disable-output-escaping attribute
( http://www.w3.org/TR/xslt#disable-output-escaping
<http://www.w3.org/TR/xslt#disable-output-escaping> ), such that you
end up with lots of <'s etc. in your xhtml (quite crippling to one's
objectives!)
=20
Is your stuff going through a .net XslTransform.Transform method? If
so, this may be the problem. In which case, your best alternative until
this is fixed is probably to use msxml3, which is much sterner stuff as
regards conformance. You can call msxml3 easily once you wrap it for
the CLR.
=20
If you aren't using .net nor outdated msxml to do xsl transforms, then
more code (specifically the source that sets the _document
property/field would probably help to clarify, as that seems to be where
the problem lies.
=20
Regards,
Stuart Salsbury
Ernst & Young LLP
=20
| [aspngbeta] member Click here to reveal e-mail address =3D YOUR ID |
http://www.asplists.com/asplists/aspngbeta.asp =3D JOIN/QUIT=20

Reply to this message...
 
 
System.Xml.Xsl.XslTransform




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification