using XSLT stylesheet on XML and deformatting html

michaelkhai

New Member
i would like to create a data feed that has the basic elements of RSS 2.0 and looks like so: \[code\]<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0"> <channel> <title>Clot3333333tory</title> <description>Clot333333333333333holesale pricing and bulk ordering to consumers and businesses.</description> <item> <title><description><link> \[/code\]i am using an XSLT stylesheet on an XML document to populate this template, a problem a have run into is i want to use a tag called \[code\]<Caption>\[/code\] in the XML document for the tag \[code\]<description>\[/code\] in the finished project. This 'Caption' field is formatted in html, i would like to pull the Caption data into 'description' but just display it as text and drop all the html tags. What would it look like in the stylesheet to do this?EDIT:
the incoming XML file looks like so(including only one 'item' element): \[code\]<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE StoreExport SYSTEM "http://store.yahoo.com/doc/dtd/StoreExport.dtd"> <StoreExport><Settings><Published timestamp="1297187196"/><Locale code="C" name="English" encoding="iso-8859-1"/> <StoreName>Clo3333333nd.com</StoreName><Currency>USD</Currency> <ShipMethods> <ShipMethod>Ground</ShipMethod> <ShipMethod>Two Day Delivery</ShipMethod> <ShipMethod>One Day Delivery</ShipMethod> <ShipMethod>3 Day</ShipMethod></ShipMethods><PayMethods> <PayMethod>American Express</PayMethod> <PayMethod>Discover</PayMethod> <PayMethod>MasterCard</PayMethod> <PayMethod>Visa</PayMethod> <PayMethod>Diner's Club</PayMethod></PayMethods></Settings><Products><Product Id="agfasu"> <Code>3616a</Code> <Description>Ageless Fashion Suit</Description> <Url>http://www.clo333333nd.com/agfasu.html</Url> <Thumb><img border=0 width=50 height=70 src=http://ep.yimg.33333333333st-27703333333618_2144_317652924></Thumb> <Picture><img border=0 width=600 height=845 src=http://ep.yimg.com/33333333-2770333333333317019111></Picture> <Orderable>YES</Orderable> <Taxable>YES</Taxable> <Pricing> <BasePrice>178.00</BasePrice> <LocalizedBasePrice>178.00</LocalizedBasePrice> <OrigPrice>299.99</OrigPrice> <LocalizedOrigPrice>299.99</LocalizedOrigPrice> <SalePrice>178.00</SalePrice> <LocalizedSalePrice>178.00</LocalizedSalePrice> </Pricing> <Path> <ProductRef Id="wochsu" Url="http://www.cl333333333333hsu.html">Womens Church Suits</ProductRef> <ProductRef Id="2454" Url="http://www.clo333333333nd.com/2454.html">Aussie Austine Spring/Summer 2011</ProductRef> </Path> <Availability>Usually ships the next business day.</Availability> <Caption><head> <meta content="en-us" http-equiv="Content-Language"> <style type="text/css"> .style3 { font-family: arial, helvetica; font-size: medium; font-weight: bold; } .style4 { font-size: small; } </style> </head> <p><strong>Wholesale Women&#39;s Church Suits&nbsp; - 3 Piece Suit - Jacket/Vest/Long Skirt</strong></p> <p><strong>Aussie Austine Spring/Summer 2011</strong></p> <p class="style4"><strong>Wholesale Clothing Distributors - Church Attire, Gospel Fashion, Mother of Bride Style at a Wholesale Price. For all your fancy, classic, elegant parties and or occasions. Our suits come in a variety of styles to accommodate your fashion taste. Suits for all women, moms, grandma&#39;s, daughters and aunts. That classic look that will bring attention. From stylish skirts, pants, jackets and vests. Two piece suits, available hats and purses. Brand Name Wholesale Ladies Apparel. </strong></p> <p>3<strong> Piece Suit - Jacket/Vest/Long Skirt</strong></p> <p><strong>Sizes&nbsp; 8 10 12 14 16 18 20</strong></p> <p><strong>Color&nbsp; Khaki Red</strong></p> <p>Available Accessories: Hat and Purse&nbsp; </p> <font face="arial, helvetica" size="4"> <p align="left">Orders of 12 and 24 Items are Mixed Colors and Sizes. For more information Please call Us @ 323333300</p> <p align="left">Please feel free to call if you would like wholesale pricing for larger orders&nbsp;</font></p> <font face="arial, helvetica" size="2"> <p align="left"><b><font size="4">Please call or E-mail <a href="mailto:Sal333333sland.com">[email protected]</a> If you are interested in purchasing larger quantities</font></b></p> </font> <p align="left" class="style3">&nbsp;</p> <p align="left">&nbsp;</p> <p align="left">&nbsp;</p> <p align="left">`</p></Caption> \[/code\]you can see the 'Caption' tag i mentioned at the bottom.
i have never used xslt before, so i currently only have a skeleton that i can only get to just basically repeat all the data, even if i use 'match' templates, all of the text is included in the final product regardless. i know i am just wording the template incorrectly, but i can find this concept explained anywhere. the wording i am using for match is: \[code\]<xsl:template match="Description"<title><apply-template/></title></xsl:template> \[/code\]with the intention of turning the 'Description' tag into a 'title' field in a final xml rss2.0 document EDIT:
okay, i am using XSLTPalette and the screen has 3 output modes: 'raw','pretty','rendered' results. when i use the stylesheet i have now to strip elements from the 'Caption' nodes, they appear like i want in the 'raw' results, it is just the text without all the escaped chars. also appears fine in the rendered result, but my data is still unstructured in the rendered result. it doesnt appear at all in the 'pretty' output box, but 'raw' is getting closer to what i need, i guess. here is an incomplete stylesheet for an example: \[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="//Product/Caption"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, '<')"> <xsl:value-of select="substring-before($text, '<')"/> <xsl:call-template name="strip-tags"> <xsl:with-param name="text" select="substring-after($text, '>')"/> </xsl:call-template> </xsl:when> <xsl:eek:therwise> <xsl:value-of select="$text"/> </xsl:eek:therwise> </xsl:choose> </xsl:template></xsl:stylesheet> \[/code\]two things: this effectively strips the correct section of nodes, but how would i also encapsulate the output of this section into a tag called 'description' for the final document, and what am i not doing to have only the things i want show up in the product, like to include nothing except what i specify i want.
 
Top