.NETGURU
URGENT! Problem with XSL Transformation in .NET XML Server Control - need a solution within the next 12 hours
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngyahoostores' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Willeus Acuna
-- Moved from [aspngfreeforall] to [aspngyahoostores] by Charles Carroll <Click here to reveal e-mail address> --

I have a source XML file coming from a Yahoo store with the contents below.
Note the embedded HTML code inside the caption node. Whenever I try to
transform this file using the .NET XML Server Control and XSLT into an HTML
page, it either shows the tags, or shows the HTML code exactly as above.

What I need is to show is the description as an HTML-formatted text, in
other words, for the control to
DECODE the encoded HTML and output that to the page. I can't seem to get the
XSLT right. Any ideas on how my XSLT should look like?

As you can probably guess, the Caption field is a result of HTML Encoding
from a multiline textbox entry field. The user is able to edit the Caption
and put in HTML tags, and these are stored into the Caption node in the
resulting XML file. Thus, on the resulting dynamic page, I need to decode
the HTML input and show the resulting HTML-formatted text onto the screen.
Of course, I can do this the hard way via the XML DOM, i.e., get the Caption
node, read the content of that node, use Server.HTMLDecode to convert back
to HTML, and assign the result onto an asp:label control. But that defeats
the purpose. XSLT is supposed to make this easier, so if anyone can help,
need a solution within the next 12 hours.

<Product Id="cc32588">
<Description>Mio Intensive Task Chair</Description>
<Orderable>NO</Orderable>
<Taxable>YES</Taxable>
<Caption><table><tr><td
height="6"></td></tr> <tr> <td align="left"
valign="top" width="100%" style><font face="arial" size="2"
color="black" class="text11"><P>The Mio is the perfect chair for
task intensive work and heavy computer use. A complete range of adjustments
that are quick and easy to change, offering maximum comfort.<P> Chairs
are made to order based on fabric color
selection.<P><P><STRONG>Features:</STRONG><P>&
lt;/B><UL> <LI>Adjustable height arms<BR>
<LI>Swivels 360 degrees<BR> <LI>Gas cylinder seat height
adjustment<BR> <LI>Backrest height adjustment - manual
knob<BR> <LI>Articulating seat and back<BR>
<LI>Infinite back angle adjustment<BR> <LI>5 degree
forward seat angle adjustment<BR> <LI>No assembly
required<BR></ul> <P><STRONG>Chair
Specifications:</STRONG><UL> <LI>Seat width: 20"<BR>
<LI>Seat depth: 20"<BR> <LI>Back width: 18"<BR>
<LI>Back height: 20"<BR> <LI>Seat height adjustment:
16.5"-21"<BR> <LI>Overall height: 41"<BR> <LI>Dual
composite foam: 3" high resiliency top layer; 3/4" high density molding
foam<BR> <LI>Casters: twin wheel nylon<BR> <LI>Arms:
height adjustable, metal stems, polyurethane arm pads<BR>
<LI>Maximum weight capacity: rated to 250 lbs.<BR>
</UL><STRONG>Fabric Specifications:</STRONG><UL>
<LI>100% polyester<BR> <LI>0.88 pounds per linear
yard<BR> <LI>210,000 double rubs<BR> <LI>Scotchguard
protective coating<BR> <LI>Passes class 1 State of CA Technical
Bulletin 117, section e CS-191-53<BR> <LI>Warranty: Limited
lifetime on chair components, 5 Years on fabric and foam
cushioning.<BR> </UL> <P></font> </td>
</tr> <tr> <td> <DIV><align="left" valign="top"
width="100%" style><font face="arial" size="2" color="black"
class="text11">Shipping will be calculated at checkout based on your
ship-to location.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Orders
containing<B> 5 or less of this item</B> will be delivered
standard UPS. <P> Orders containing <B>6 or more of this
item</B> will be delivered via common carrier, who will call to set up
a delivery appointment, deliver curbside and require a signature.
<B><I><P>Note:</B></I><font
color="blue"> To ensure prompt and correct delivery, please include your
daytime phone number in the shipping information at the time of check out.
</P></font> Please remember that extraordinary delivery
requirements may necessitate an additional fee from the
carrier.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Delivery is not
available to Alaska and Hawaii.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black"
class="text11"><BR><BR></font></DIV> </td>
<tr> <tr> <td> <font face="arial" size="2"
color="#555555" class="text11" style="color: #555555">[Model
4021A]<br><br></font> </td> </tr>
</table></Caption>
</Product>

Willeus Acuna
www.hotblue.com

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: Thursday, March 07, 2002 2:42 AM
To: Click here to reveal e-mail address
Cc: Click here to reveal e-mail address
Subject: Re: [aspngxml] URGENT! Problem with XSL Transformation in .NET XML
Server Con...

Hello,

I would first say that XML data is not intended to contain markup, you
should put that into your XSLT. It should be in your xsl file as...

<B><xsl:value-of select="sample/greeting"/></B>

I haven't tested this, but this may work...

<sample>
<greeting><B>Hi There</B></greeting>
</sample>

John McMillion
Senior Software Engineer
Click here to reveal e-mail address
http://www.johnmcmillion.com

In a message dated 3/6/2002 6:48:15 AM Pacific Standard Time,
Click here to reveal e-mail address writes:

I have a source XML file (simplified, of course):

<sample>
<greeting><b>Hi There</b></greeting>
</sample>

Note the embedded HTML code inside the greeting node. Whenever I try to
transform this file using the .NET XML Server Control and XSLT into an HTML
page, it either shows the tags, or shows the HTML code exactly as above.

What I need is to show a bold "Hi There", in other words, for the control to
DECODE the encoded HTML and output that to the page. I can't seem to get the
XSLT right. Any ideas on how my XSLT should look like?

Reply to this message...
 
    
Mitch Denny (VIP)
Willeus,

Its unfortunate that Yahoo! serializes the data this way when
it generates this file. Normally you want to do the opposite
and have your XSLT spit out the data so that the HTML tags
are visible. At this stage in the processing game you'll
probably need to pre-process the file performing a HtmlDecode
on each of the Caption elements.

Here is some code in C# that does it:

using System;
using System.Web;
using System.Xml;

public class QuickDecode
{

    public static void Main()
    {

        // Declare locals.
        XmlDocument productCatalog = null;
        XmlNodeList productCaptions = null;

        // Load the product catalog.
        productCatalog = new XmlDocument();
        productCatalog.Load(@"..\..\ProductCatalog.xml");

        // Grab a collection of all the product captions.
        productCaptions =
productCatalog.SelectNodes("/Products/Product/Caption");

        // Enumerate over the collection grabbing each node one
by one.
        foreach (XmlNode productCaption in productCaptions)
        {

            // HTML decode the contents of each node.
            productCaption.InnerXml =
HttpUtility.HtmlDecode(productCaption.InnerXml);

        }

        // Output modified XML document to screen.
        Console.WriteLine(productCatalog.OuterXml);

    }

}

Here is the document that it is working against:

<?xml version="1.0" encoding="utf-8" ?>

<Products>
    <Product>
        <Caption><b>Product 1</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 2</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 3</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 4</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 5</b></Caption>
    </Product>
</Products>

It should spit out a messier version of this:

<?xml version="1.0" encoding="utf-8" ?>

<Products>
    <Product>
        <Caption><b>Product 1</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 2</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 3</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 4</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 5</b></Caption>
    </Product>
</Products>

Let me know if you need a version of the code written
in VB.NET. Hope this helps.

----------------------------------------
- Mitch Denny
- Click here to reveal e-mail address
- +61 (414) 610-141
-

-----Original Message-----
From: Willeus Acuna [mailto:Click here to reveal e-mail address]
Sent: Tuesday, 26 March 2002 10:42
To: Click here to reveal e-mail address
Subject: [aspngyahoostores] URGENT! Problem with XSL Transformation in
.NET XML Server Control - need a solution within the next 12 hours

-- Moved from [aspngfreeforall] to [aspngyahoostores] by Charles Carroll
<Click here to reveal e-mail address> --

I have a source XML file coming from a Yahoo store with the contents
below. Note the embedded HTML code inside the caption node. Whenever I
try to transform this file using the .NET XML Server Control and XSLT
into an HTML page, it either shows the tags, or shows the HTML code
exactly as above.

What I need is to show is the description as an HTML-formatted text, in
other words, for the control to DECODE the encoded HTML and output that
to the page. I can't seem to get the XSLT right. Any ideas on how my
XSLT should look like?

As you can probably guess, the Caption field is a result of HTML
Encoding from a multiline textbox entry field. The user is able to edit
the Caption and put in HTML tags, and these are stored into the Caption
node in the resulting XML file. Thus, on the resulting dynamic page, I
need to decode the HTML input and show the resulting HTML-formatted text
onto the screen. Of course, I can do this the hard way via the XML DOM,
i.e., get the Caption node, read the content of that node, use
Server.HTMLDecode to convert back to HTML, and assign the result onto an
asp:label control. But that defeats the purpose. XSLT is supposed to
make this easier, so if anyone can help, need a solution within the next
12 hours.

<Product Id="cc32588">
<Description>Mio Intensive Task Chair</Description>
<Orderable>NO</Orderable>
<Taxable>YES</Taxable>
<Caption><table><tr><td
height="6"></td></tr> <tr> <td align="left"
valign="top" width="100%" style><font face="arial" size="2"
color="black" class="text11"><P>The Mio is the perfect chair
for task intensive work and heavy computer use. A complete range of
adjustments that are quick and easy to change, offering maximum
comfort.<P> Chairs are made to order based on fabric color
selection.<P><P><STRONG>Features:</STRONG><P&
gt;&
lt;/B><UL> <LI>Adjustable he
arms<BR>
<LI>Swivels 360 degrees<BR> <LI>Gas cylinder seat
height adjustment<BR> <LI>Backrest height adjustment -
manual knob<BR> <LI>Articulating seat and back<BR>
<LI>Infinite back angle adjustment<BR> <LI>5 degree
forward seat angle adjustment<BR> <LI>No assembly
required<BR></ul> <P><STRONG>Chair
Specifications:</STRONG><UL> <LI>Seat width:
20"<BR> <LI>Seat depth: 20"<BR> <LI>Back width:
18"<BR> <LI>Back height: 20"<BR> <LI>Seat height
adjustment: 16.5"-21"<BR> <LI>Overall height: 41"<BR>
<LI>Dual composite foam: 3" high resiliency top layer; 3/4" high
density molding foam<BR> <LI>Casters: twin wheel
nylon<BR> <LI>Arms: height adjustable, metal stems,
polyurethane arm pads<BR> <LI>Maximum weight capacity: rated
to 250 lbs.<BR> </UL><STRONG>Fabric
Specifications:</STRONG><UL>
<LI>100% polyester<BR> <LI>0.88 pounds per linear
yard<BR> <LI>210,000 double rubs<BR>
<LI>Scotchguard protective coating<BR> <LI>Passes
class 1 State of CA Technical Bulletin 117, section e
CS-191-53<BR> <LI>Warranty: Limited lifetime on chair
components, 5 Years on fabric and foam cushioning.<BR> </UL>
<P></font> </td> </tr> <tr> <td>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Shipping will be
calculated at checkout based on your ship-to
location.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Orders
containing<B> 5 or less of this item</B> will be delivered
standard UPS. <P> Orders containing <B>6 or more of this
item</B> will be de via common carrier, who will call to set up a
delivery appointment, deliver curbside and require a signature.
<B><I><P>Note:</B></I><font
color="blue"> To ensure prompt and correct delivery, please include
your daytime phone number in the shipping information at the time of
check out. </P></font> Please remember that extraordinary
delivery requirements may necessitate an additional fee from the
carrier.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Delivery is not
available to Alaska and
Hawaii.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black"
class="text11"><BR><BR></font></DIV>
</td> <tr> <tr> <td> <font face="arial"
size="2" color="#555555" class="text11" style="color: #555555">[Model
4021A]<br><br></font> </td> </tr>
</table></Caption> </Product>

Willeus Acuna
www.hotblue.com

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: Thursday, March 07, 2002 2:42 AM
To: Click here to reveal e-mail address
Cc: Click here to reveal e-mail address
Subject: Re: [aspngxml] URGENT! Problem with XSL Transformation in .NET
XML Server Con...

Hello,

I would first say that XML data is not intended to contain markup, you
should put that into your XSLT. It should be in your xsl file as...

<B><xsl:value-of select="sample/greeting"/></B>

I haven't tested this, but this may work...

<sample>
<greeting><B>Hi There</B></greeting> </sample>

John McMillion
Senior Software Engineer
Click here to reveal e-mail address
http://www.johnmcmillion.com

In a message dated 3/6/2002 6:48:15 AM Pacific Standard Time,
Click here to reveal e-mail address writes:

I have a source XML file (simplified, of course):

<sample>
<greeting><b>Hi There</b></gre
code inside the greeting node. Whenever I try to
transform this file using the .NET XML Server Control and XSLT into an
HTML page, it either shows the tags, or shows the HTML code exactly as
above.

What I need is to show a bold "Hi There", in other words, for the
control to DECODE the encoded HTML and output that to the page. I can't
seem to get the XSLT right. Any ideas on how my XSLT should look like?

Reply to this message...
 
    
Willeus Acuna
Mitch Denny,

Thank you for the input... but I did find a way to do it straight from XSLT
:)

When you want to show the code as it is, you can use this construct:

<xsl:value-of select="text()|*" disable-output-escaping="yes" />

Works beautifully.

Willeus Acuna
HotBlue Software Solutions, Inc.
www.hotblue.com

*** When you need top-quality ASP.NET developers, go to HotBlue first! Visit
www.hotblue.com today
*** Save time & effort w/ quality website templates for as low as $14.95.
Visit www.hotblue.com/templates.aspx today!

-----Original Message-----
From: Mitch Denny [mailto:Click here to reveal e-mail address]
Sent: Tuesday, March 26, 2002 8:38 AM
To: aspngyahoostores
Subject: [aspngyahoostores] RE: URGENT! Problem with XSL Transformation
in .NET XML Server Control - need a solution within the next 12 hours

Willeus,

Its unfortunate that Yahoo! serializes the data this way when
it generates this file. Normally you want to do the opposite
and have your XSLT spit out the data so that the HTML tags
are visible. At this stage in the processing game you'll
probably need to pre-process the file performing a HtmlDecode
on each of the Caption elements.

Here is some code in C# that does it:

using System;
using System.Web;
using System.Xml;

public class QuickDecode
{

    public static void Main()
    {

        // Declare locals.
        XmlDocument productCatalog = null;
        XmlNodeList productCaptions = null;

        // Load the product catalog.
        productCatalog = new XmlDocument();
        productCatalog.Load(@"..\..\ProductCatalog.xml");

        // Grab a collection of all the product captions.
        productCaptions =
productCatalog.SelectNodes("/Products/Product/Caption");

        // Enumerate over the collection grabbing each node one
by one.
        foreach (XmlNode productCaption in productCaptions)
        {

            // HTML decode the contents of each node.
            productCaption.InnerXml =
HttpUtility.HtmlDecode(productCaption.InnerXml);

        }

        // Output modified XML document to screen.
        Console.WriteLine(productCatalog.OuterXml);

    }

}

Here is the document that it is working against:

<?xml version="1.0" encoding="utf-8" ?>

<Products>
    <Product>
        <Caption><b>Product 1</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 2</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 3</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 4</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 5</b></Caption>
    </Product>
</Products>

It should spit out a messier version of this:

<?xml version="1.0" encoding="utf-8" ?>

<Products>
    <Product>
        <Caption><b>Product 1</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 2</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 3</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 4</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 5</b></Caption>
    </Product>
</Products>

Let me know if you need a version of the code written
in VB.NET. Hope this helps.

----------------------------------------
- Mitch Denny
- Click here to reveal e-mail address
- +61 (414) 610-141
-

-----Original Message-----
From: Willeus Acuna [mailto:Click here to reveal e-mail address]
Sent: Tuesday, 26 March 2002 10:42
To: Click here to reveal e-mail address
Subject: [aspngyahoostores] URGENT! Problem with XSL Transformation in
.NET XML Server Control - need a solution within the next 12 hours

-- Moved from [aspngfreeforall] to [aspngyahoostores] by Charles Carroll
<Click here to reveal e-mail address> --

I have a source XML file coming from a Yahoo store with the contents
below. Note the embedded HTML code inside the caption node. Whenever I
try to transform this file using the .NET XML Server Control and XSLT
into an HTML page, it either shows the tags, or shows the HTML code
exactly as above.

What I need is to show is the description as an HTML-formatted text, in
other words, for the control to DECODE the encoded HTML and output that
to the page. I can't seem to get the XSLT right. Any ideas on how my
XSLT should look like?

As you can probably guess, the Caption field is a result of HTML
Encoding from a multiline textbox entry field. The user is able to edit
the Caption and put in HTML tags, and these are stored into the Caption
node in the resulting XML file. Thus, on the resulting dynamic page, I
need to decode the HTML input and show the resulting HTML-formatted text
onto the screen. Of course, I can do this the hard way via the XML DOM,
i.e., get the Caption node, read the content of that node, use
Server.HTMLDecode to convert back to HTML, and assign the result onto an
asp:label control. But that defeats the purpose. XSLT is supposed to
make this easier, so if anyone can help, need a solution within the next
12 hours.

<Product Id="cc32588">
<Description>Mio Intensive Task Chair</Description>
<Orderable>NO</Orderable>
<Taxable>YES</Taxable>
<Caption><table><tr><td
height="6"></td></tr> <tr> <td align="left"
valign="top" width="100%" style><font face="arial" size="2"
color="black" class="text11"><P>The Mio is the perfect chair
for task intensive work and heavy computer use. A complete range of
adjustments that are quick and easy to change, offering maximum
comfort.<P> Chairs are made to order based on fabric color
selection.<P><P><STRONG>Features:</STRONG><P&
gt;&
lt;/B><UL> <LI>Adjustable he
arms<BR>
<LI>Swivels 360 degrees<BR> <LI>Gas cylinder seat
height adjustment<BR> <LI>Backrest height adjustment -
manual knob<BR> <LI>Articulating seat and back<BR>
<LI>Infinite back angle adjustment<BR> <LI>5 degree
forward seat angle adjustment<BR> <LI>No assembly
required<BR></ul> <P><STRONG>Chair
Specifications:</STRONG><UL> <LI>Seat width:
20"<BR> <LI>Seat depth: 20"<BR> <LI>Back width:
18"<BR> <LI>Back height: 20"<BR> <LI>Seat height
adjustment: 16.5"-21"<BR> <LI>Overall height: 41"<BR>
<LI>Dual composite foam: 3" high resiliency top layer; 3/4" high
density molding foam<BR> <LI>Casters: twin wheel
nylon<BR> <LI>Arms: height adjustable, metal stems,
polyurethane arm pads<BR> <LI>Maximum weight capacity: rated
to 250 lbs.<BR> </UL><STRONG>Fabric
Specifications:</STRONG><UL>
<LI>100% polyester<BR> <LI>0.88 pounds per linear
yard<BR> <LI>210,000 double rubs<BR>
<LI>Scotchguard protective coating<BR> <LI>Passes
class 1 State of CA Technical Bulletin 117, section e
CS-191-53<BR> <LI>Warranty: Limited lifetime on chair
components, 5 Years on fabric and foam cushioning.<BR> </UL>
<P></font> </td> </tr> <tr> <td>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Shipping will be
calculated at checkout based on your ship-to
location.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Orders
containing<B> 5 or less of this item</B> will be delivered
standard UPS. <P> Orders containing <B>6 or more of this
item</B> will be de via common carrier, who will call to set up a
delivery appointment, deliver curbside and require a signature.
<B><I><P>Note:</B></I><font
color="blue"> To ensure prompt and correct delivery, please include
your daytime phone number in the shipping information at the time of
check out. </P></font> Please remember that extraordinary
delivery requirements may necessitate an additional fee from the
carrier.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Delivery is not
available to Alaska and
Hawaii.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black"
class="text11"><BR><BR></font></DIV>
</td> <tr> <tr> <td> <font face="arial"
size="2" color="#555555" class="text11" style="color: #555555">[Model
4021A]<br><br></font> </td> </tr>
</table></Caption> </Product>

Willeus Acuna
www.hotblue.com

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: Thursday, March 07, 2002 2:42 AM
To: Click here to reveal e-mail address
Cc: Click here to reveal e-mail address
Subject: Re: [aspngxml] URGENT! Problem with XSL Transformation in .NET
XML Server Con...

Hello,

I would first say that XML data is not intended to contain markup, you
should put that into your XSLT. It should be in your xsl file as...

<B><xsl:value-of select="sample/greeting"/></B>

I haven't tested this, but this may work...

<sample>
<greeting><B>Hi There</B></greeting> </sample>

John McMillion
Senior Software Engineer
Click here to reveal e-mail address
http://www.johnmcmillion.com

In a message dated 3/6/2002 6:48:15 AM Pacific Standard Time,
Click here to reveal e-mail address writes:

I have a source XML file (simplified, of course):

<sample>
<greeting><b>Hi There</b></gre
code inside the greeting node. Whenever I try to
transform this file using the .NET XML Server Control and XSLT into an
HTML page, it either shows the tags, or shows the HTML code exactly as
above.

What I need is to show a bold "Hi There", in other words, for the
control to DECODE the encoded HTML and output that to the page. I can't
seem to get the XSLT right. Any ideas on how my XSLT should look like?

| [aspngyahoostores] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngyahoostores.asp = JOIN/QUIT

Reply to this message...
 
    
Mitch Denny (VIP)
Willeus,

Well you learn something new everyday. Thanks for the
tip, committing to long term storage.

----------------------------------------
- Mitch Denny
- Click here to reveal e-mail address
- +61 (414) 610-141
-

-----Original Message-----
From: Willeus Acuna [mailto:Click here to reveal e-mail address]
Sent: Monday, 26 March 2001 15:01
To: aspngyahoostores
Subject: [aspngyahoostores] RE: URGENT! Problem with XSL Transformation
in .NET XML Server Control - need a solution within the next 12 hours

Mitch Denny,

Thank you for the input... but I did find a way to do it straight from
XSLT
:)

When you want to show the code as it is, you can use this construct:

<xsl:value-of select="text()|*" disable-output-escaping="yes" />

Works beautifully.

Willeus Acuna
HotBlue Software Solutions, Inc.
www.hotblue.com

*** When you need top-quality ASP.NET developers, go to HotBlue first!
Visit www.hotblue.com today
*** Save time & effort w/ quality website templates for as low as
$14.95. Visit www.hotblue.com/templates.aspx today!

-----Original Message-----
From: Mitch Denny [mailto:Click here to reveal e-mail address]
Sent: Tuesday, March 26, 2002 8:38 AM
To: aspngyahoostores
Subject: [aspngyahoostores] RE: URGENT! Problem with XSL Transformation
in .NET XML Server Control - need a solution within the next 12 hours

Willeus,

Its unfortunate that Yahoo! serializes the data this way when it
generates this file. Normally you want to do the opposite and have your
XSLT spit out the data so that the HTML tags are visible. At this stage
in the processing game you'll probably need to pre-process the file
performing a HtmlDecode on each of the Caption elements.

Here is some code in C# that does it:

using System;
using System.Web;
using System.Xml;

public class QuickDecode
{

    public static void Main()
    {

        // Declare locals.
        XmlDocument productCatalog = null;
        XmlNodeList productCaptions = null;

        // Load the product catalog.
        productCatalog = new XmlDocument();
        productCatalog.Load(@"..\..\ProductCatalog.xml");

        // Grab a collection of all the product captions.
        productCaptions =
productCatalog.SelectNodes("/Products/Product/Caption");

        // Enumerate over the collection grabbing each node one
by one.
        foreach (XmlNode productCaption in productCaptions)
        {

            // HTML decode the contents of each node.
            productCaption.InnerXml =
HttpUtility.HtmlDecode(productCaption.InnerXml);

        }

        // Output modified XML document to screen.
        Console.WriteLine(productCatalog.OuterXml);

    }

}

Here is the document that it is working against:

<?xml version="1.0" encoding="utf-8" ?>

<Products>
    <Product>
        <Caption><b>Product 1</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 2</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 3</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 4</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 5</b></Caption>
    </Product>
</Products>

It should spit out a messier version of this:

<?xml version="1.0" encoding="utf-8" ?>

<Products>
    <Product>
        <Caption><b>Product 1</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 2</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 3</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 4</b></Caption>
    </Product>
    <Product>
        <Caption><b>Product 5</b></Caption>
    </Product>
</Products>

Let me know if you need a version of the code written
in VB.NET. Hope this helps.

----------------------------------------
- Mitch Denny
- Click here to reveal e-mail address
- +61 (414) 610-141
-

-----Original Message-----
From: Willeus Acuna [mailto:Click here to reveal e-mail address]
Sent: Tuesday, 26 March 2002 10:42
To: Click here to reveal e-mail address
Subject: [aspngyahoostores] URGENT! Problem with XSL Transformation in
.NET XML Server Control - need a solution within the next 12 hours

-- Moved from [aspngfreeforall] to [aspngyahoostores] by Charles Carroll
<Click here to reveal e-mail address> --

I have a source XML file coming from a Yahoo store with the contents
below. Note the embedded HTML code inside the caption node. Whenever I
try to transform this file using the .NET XML Server Control and XSLT
into an HTML page, it either shows the tags, or shows the HTML code
exactly as above.

What I need is to show is the description as an HTML-formatted text, in
other words, for the control to DECODE the encoded HTML and output that
to the page. I can't seem to get the XSLT right. Any ideas on how my
XSLT should look like?

As you can probably guess, the Caption field is a result of HTML
Encoding from a multiline textbox entry field. The user is able to edit
the Caption and put in HTML tags, and these are stored into the Caption
node in the resulting XML file. Thus, on the resulting dynamic page, I
need to decode the HTML input and show the resulting HTML-formatted text
onto the screen. Of course, I can do this the hard way via the XML DOM,
i.e., get the Caption node, read the content of that node, use
Server.HTMLDecode to convert back to HTML, and assign the result onto an
asp:label control. But that defeats the purpose. XSLT is supposed to
make this easier, so if anyone can help, need a solution within the next
12 hours.

<Product Id="cc32588">
<Description>Mio Intensive Task Chair</Description>
<Orderable>NO</Orderable>
<Taxable>YES</Taxable>
<Caption><table><tr><td
height="6"></td></tr> <tr> <td align="left"
valign="top" width="100%" style><font face="arial" size="2"
color="black" class="text11"><P>The Mio is the perfect chair
for task intensive work and heavy computer use. A complete range of
adjustments that are quick and easy to change, offering maximum
comfort.<P> Chairs are made to order based on fabric color
selection.<P><P><STRONG>Features:</STRONG><P&
gt;&
lt;/B><UL> <LI>Adjustable he
arms<BR>
<LI>Swivels 360 degrees<BR> <LI>Gas cylinder seat
height adjustment<BR> <LI>Backrest height adjustment -
manual knob<BR> <LI>Articulating seat and back<BR>
<LI>Infinite back angle adjustment<BR> <LI>5 degree
forward seat angle adjustment<BR> <LI>No assembly
required<BR></ul> <P><STRONG>Chair
Specifications:</STRONG><UL> <LI>Seat width:
20"<BR> <LI>Seat depth: 20"<BR> <LI>Back width:
18"<BR> <LI>Back height: 20"<BR> <LI>Seat height
adjustment: 16.5"-21"<BR> <LI>Overall height: 41"<BR>
<LI>Dual composite foam: 3" high resiliency top layer; 3/4" high
density molding foam<BR> <LI>Casters: twin wheel
nylon<BR> <LI>Arms: height adjustable, metal stems,
polyurethane arm pads<BR> <LI>Maximum weight capacity: rated
to 250 lbs.<BR> </UL><STRONG>Fabric
Specifications:</STRONG><UL>
<LI>100% polyester<BR> <LI>0.88 pounds per linear
yard<BR> <LI>210,000 double rubs<BR>
<LI>Scotchguard protective coating<BR> <LI>Passes
class 1 State of CA Technical Bulletin 117, section e
CS-191-53<BR> <LI>Warranty: Limited lifetime on chair
components, 5 Years on fabric and foam cushioning.<BR> </UL>
<P></font> </td> </tr> <tr> <td>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Shipping will be
calculated at checkout based on your ship-to
location.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Orders
containing<B> 5 or less of this item</B> will be delivered
standard UPS. <P> Orders containing <B>6 or more of this
item</B> will be de via common carrier, who will call to set up a
delivery appointment, deliver curbside and require a signature.
<B><I><P>Note:</B></I><font
color="blue"> To ensure prompt and correct delivery, please include
your daytime phone number in the shipping information at the time of
check out. </P></font> Please remember that extraordinary
delivery requirements may necessitate an additional fee from the
carrier.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black" class="text11">Delivery is not
available to Alaska and
Hawaii.<BR><BR></font></DIV>
<DIV><align="left" valign="top" width="100%" style><font
face="arial" size="2" color="black"
class="text11"><BR><BR></font></DIV>
</td> <tr> <tr> <td> <font face="arial"
size="2" color="#555555" class="text11" style="color: #555555">[Model
4021A]<br><br></font> </td> </tr>
</table></Caption> </Product>

Willeus Acuna
www.hotblue.com

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: Thursday, March 07, 2002 2:42 AM
To: Click here to reveal e-mail address
Cc: Click here to reveal e-mail address
Subject: Re: [aspngxml] URGENT! Problem with XSL Transformation in .NET
XML Server Con...

Hello,

I would first say that XML data is not intended to contain markup, you
should put that into your XSLT. It should be in your xsl file as...

<B><xsl:value-of select="sample/greeting"/></B>

I haven't tested this, but this may work...

<sample>
<greeting><B>Hi There</B></greeting> </sample>

John McMillion
Senior Software Engineer
Click here to reveal e-mail address
http://www.johnmcmillion.com

In a message dated 3/6/2002 6:48:15 AM Pacific Standard Time,
Click here to reveal e-mail address writes:

I have a source XML file (simplified, of course):

<sample>
<greeting><b>Hi There</b></gre
code inside the greeting node. Whenever I try to
transform this file using the .NET XML Server Control and XSLT into an
HTML page, it either shows the tags, or shows the HTML code exactly as
above.

What I need is to show a bold "Hi There", in other words, for the
control to DECODE the encoded HTML and output that to the page. I can't
seem to get the XSLT right. Any ideas on how my XSLT should look like?

| [aspngyahoostores] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngyahoostores.asp = JOIN/QUIT

| [aspngyahoostores] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngyahoostores.asp = JOIN/QUIT

Reply to this message...
 
 
System.Console
System.Web.HttpUtility
System.Xml.XmlDocument
System.Xml.XmlNode
System.Xml.XmlNodeList




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