ivelin 2002/10/28 19:26:38 Modified: src/webapp/samples/webserviceproxy sitemap.xmap Added: src/webapp/samples/webserviceproxy/cocoonhive sitemap.xmap src/webapp/samples/webserviceproxy/cocoonhive/amazon listMania2xhtml.xsl bookInfo2xhtml.xsl bookInfo2page.xsl Log: added a more sophisticated demo for the WebServiceProxyGenerator. Show cases virtual portal embedding Amazon and OpenWiki Revision Changes Path 1.6 +31 -31 xml-cocoon2/src/webapp/samples/webserviceproxy/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/xml-cocoon2/src/webapp/samples/webserviceproxy/sitemap.xmap,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- sitemap.xmap 27 Oct 2002 07:37:05 -0000 1.5 +++ sitemap.xmap 29 Oct 2002 03:26:38 -0000 1.6 @@ -1,35 +1,35 @@ <?xml version="1.0"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> - - <!-- =========================== Views =================================== --> - - <map:views> - <map:view name="xml" from-label="xml"> - <map:serialize type="xml"/> - </map:view> - </map:views> - - <!-- =========================== Pipelines ================================= --> - <map:pipelines> - <map:pipeline> - - <!-- Interactive Web Application Syndication --> - <map:match pattern="*"> - - <map:generate type="wsproxy" - - src="http://localhost:8080/cocoon/samples/xmlform/wizard?cocoon-view=xml" - label="xml"/> - - <!-- This line is temporarily hidden, due to problem with the InputModule --> - <!-- src="http://{header:host}/cocoon/samples/xmlform/wizard?cocoon-view=xml" --> - - <map:transform src="stylesheets/newWizard2html.xsl" /> - <map:transform src="context://samples/stylesheets/xmlform/xmlform2html.xsl"/> - <map:serialize type="html"/> - </map:match> - </map:pipeline> - </map:pipelines> + <!-- =========================== Views =================================== --> + <map:views> + <map:view name="xml" from-label="xml"> + <map:serialize type="xml"/> + </map:view> + </map:views> + <!-- =========================== Pipelines ================================= --> + <map:pipelines> + <!-- pipeline mounting Cocoon hive portal demo --> + <map:pipeline> + <!-- mount everything else --> + <map:match pattern="cocoonhive/**"> + <map:mount check-reload="yes" src="cocoonhive/" uri-prefix="cocoonhive"/> + </map:match> + </map:pipeline> + <map:pipeline> + <!-- Interactive Web Application Syndication --> + <map:match pattern="*"> + <map:generate type="wsproxy" + src="http://localhost:8080/cocoon/samples/xmlform/wizard?cocoon-view=xml" + label="xml"/> + <!-- This line is temporarily hidden, due to problem with the InputModule --> + <!-- src="http://{header:host}/cocoon/samples/xmlform/wizard?cocoon-view=xml" --> + <map:transform src="stylesheets/newWizard2html.xsl" /> + <map:transform + src="context://samples/stylesheets/xmlform/xmlform2html.xsl" + /> + <map:serialize type="html"/> + </map:match> + </map:pipeline> + </map:pipelines> </map:sitemap> <!-- end of file --> - 1.1 xml-cocoon2/src/webapp/samples/webserviceproxy/cocoonhive/sitemap.xmap Index: sitemap.xmap =================================================================== <?xml version="1.0"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <!-- =========================== Resources ================================= --> <map:resources> <map:resource name="home"> <!-- Load the home page frame --> <map:generate src="portal/home.xml" label="xml"/> <!-- Resolve CInclude references to remote services --> <map:transform type="cinclude"/> <!-- Dress up the content in a customized skin --> <map:transform src="stylesheets/page2html.xsl"/> <map:serialize type="html"/> </map:resource> </map:resources> <!-- =========================== Pipelines ================================= --> <map:pipelines> <map:pipeline> <!-- Portal content is not likely to expire within an hour --> <!-- This greatly improves user experience --> <map:parameter name="expires" value="access plus 1 hours"/> <!-- Portal Syndication - Home --> <map:match pattern=""> <map:call resource="home"/> </map:match> <!-- Commands section --> <map:match pattern="home"> <map:call resource="home"/> </map:match> <!-- Amazon.com section --> <map:match pattern="frame-amazon"> <map:generate src="cocoon:/amazon-listMania-resource"/> <map:serialize type="xml"/> </map:match> <map:match pattern="page-amazon-listMania*"> <map:generate src="cocoon:/amazon-listMania-resource"/> <map:transform src="stylesheets/service2page.xsl"> <map:parameter name="title" value="Amazon List Mania"/> </map:transform> <map:transform src="stylesheets/page2html.xsl"/> <map:serialize type="html"/> </map:match> <map:match pattern="page-amazon-bookInfo*"> <map:generate src="cocoon:/amazon-bookInfo-resource"/> <map:transform src="stylesheets/service2page.xsl"> <map:parameter name="title" value="Amazon Book Details"/> </map:transform> <map:transform src="amazon/bookInfo2page.xsl"/> <map:transform src="stylesheets/page2html.xsl"/> <map:serialize type="html"/> </map:match> <!-- OpenWiki.com section --> <map:match pattern="frame-openWiki"> <map:generate src="cocoon:/openWiki-resource"/> <map:serialize type="xml"/> </map:match> <map:match pattern="ow.asp*"> <map:generate src="cocoon:/openWiki-resource"/> <map:transform src="stylesheets/service2page.xsl"> <map:parameter name="title" value="OpenWiki"/> </map:transform> <map:transform src="stylesheets/page2html.xsl"/> <map:serialize type="html"/> </map:match> <map:match pattern="openWiki"> <map:generate src="cocoon:/openWiki-resource"/> <map:serialize type="xhtml"/> </map:match> </map:pipeline> <!-- Internal resources (@todo should be moved in a resource section?) --> <map:pipeline> <map:match pattern="amazon-listMania-resource"> <map:generate type="wsproxy" src="http://xml.amazon.com/onca/xml?v=1.0&t=webservices-20&dev-t=D2GNXHNXXYM094&ListManiaSearch=1AU8KSU46JLPD&type=lite&f=xml" label="xml"/> <map:transform src="amazon/listMania2xhtml.xsl"/> <map:serialize type="xhtml"/> </map:match> <map:match pattern="amazon-bookInfo-resource"> <map:generate type="wsproxy" src="http://xml.amazon.com/onca/xml?v=1.0&t=webservices-20&dev-t=D2GNXHNXXYM094&type=heavy&f=xml" label="xml"/> <map:transform src="amazon/bookInfo2xhtml.xsl"/> <map:serialize type="xhtml"/> </map:match> <map:match pattern="openWiki-resource"> <map:generate type="wsproxy" src="http://www.openwiki.com/ow.asp?a=xml&xml=1" label="xml"/> <map:transform type="xalan" src="ow/xsl/ow.xsl"/> <map:serialize type="xml"/> </map:match> </map:pipeline> <map:pipeline> <map:parameter name="expires" value="access plus 1 hours"/> <!-- Static files section --> <map:match pattern="stylesheets/*"> <map:read src="stylesheets/{1}"/> </map:match> <map:match pattern="ow/**"> <map:read src="http://www.openwiki.com/ow/{1}"/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> <!-- end of file --> 1.1 xml-cocoon2/src/webapp/samples/webserviceproxy/cocoonhive/amazon/listMania2xhtml.xsl Index: listMania2xhtml.xsl =================================================================== <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd"/> <xsl:template match="/ProductInfo"> <table class="content table"> <xsl:if test="Details"> <xsl:call-template name="bookRow"> <xsl:with-param name="bookDetailsSet" select="Details"/> </xsl:call-template> </xsl:if> <xsl:apply-templates select="ErrorMsg"/> </table> </xsl:template> <!-- render multiple rows, each listing 3 books --> <xsl:template name="bookRow"> <xsl:param name="bookDetailsSet"/> <xsl:if test="$bookDetailsSet"> <tr> <xsl:for-each select="$bookDetailsSet[position() < 4]"> <xsl:call-template name="bookInfo"/> </xsl:for-each> </tr> <xsl:call-template name="bookRow"> <xsl:with-param name="bookDetailsSet" select="$bookDetailsSet[position() > 3]"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="bookInfo"> <td> <xsl:element name="a"> <xsl:attribute name="href">page-amazon-bookInfo?AsinSearch=<xsl:value-of select="Asin"/></xsl:attribute> <xsl:element name="img"> <xsl:attribute name="src"><xsl:value-of select="ImageUrlSmall"/></xsl:attribute> <xsl:attribute name="alt">cover art</xsl:attribute> </xsl:element> </xsl:element> </td> <TD> <xsl:element name="a"> <xsl:attribute name="href">page-amazon-bookInfo?AsinSearch=<xsl:value-of select="Asin"/></xsl:attribute> <FONT face="Arial" size="-2" color="3366FF"> <xsl:value-of select="ProductName"/> </FONT> <br/> </xsl:element> <FONT face="Arial" size="-2" color="000000"> <xsl:value-of select="Manufacturer"/> </FONT> <br/> <font face="Arial" size="-2"> <font color="990000">New <xsl:value-of select="OurPrice"/></font> </font> </TD> </xsl:template> <xsl:template match="ErrorMsg"> <div title="Error Message"> <xsl:value-of select="."/> </div> </xsl:template> </xsl:stylesheet> 1.1 xml-cocoon2/src/webapp/samples/webserviceproxy/cocoonhive/amazon/bookInfo2xhtml.xsl Index: bookInfo2xhtml.xsl =================================================================== <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd"/> <xsl:template match="/"> <xsl:apply-templates select="ProductInfo/Details"/> </xsl:template> <xsl:template match="Details"> <table border="0" width="100%" cellpadding="5"> <tr> <td rowspan="4"> <img src="{ImageUrlMedium}"/> </td> <td> <b><u><font size="+1"><xsl:value-of select="ProductName"/></font></u></b> </td> </tr> <tr> <td> <b> <xsl:text>Published: </xsl:text> </b> <xsl:value-of select="ReleaseDate"/> </td> </tr> <tr> <td> <xsl:call-template name="OurPrice"> <xsl:with-param name="OurPrice" select="substring(OurPrice, 2)"/> <xsl:with-param name="ListPrice" select="substring(ListPrice, 2)"/> </xsl:call-template> <xsl:apply-templates select="UsedPrice | CollectiblePrice | ThirdPartyNewPrice"/> <xsl:apply-templates select="SalesRank"/> </td> </tr> <tr> <td> <xsl:apply-templates select="Authors"/> </td> </tr> <tr> <td> <xsl:call-template name="BuyButton"> <xsl:with-param name="Asin" select="Asin"/> </xsl:call-template> </td> </tr> <xsl:apply-templates select="Reviews/AvgCustomerRating"/> <xsl:apply-templates select="Reviews/CustomerReview"> <xsl:sort select="Rating"/> </xsl:apply-templates> </table> <hr/> </xsl:template> <xsl:template name="OurPrice"> <xsl:param name="OurPrice" select="'1.00'"/> <xsl:param name="ListPrice" select="'1.00'"/> <xsl:param name="UsedPrice"/> <xsl:param name="CollectiblePrice"/> <xsl:param name="ThirdPartyNewPrice"/> <xsl:choose> <xsl:when test="$OurPrice = $ListPrice"> <b>Our price: </b><xsl:text>$</xsl:text> <xsl:value-of select="$OurPrice"/> </xsl:when> <xsl:otherwise> <b>Our price: </b><xsl:text>$</xsl:text> <xsl:value-of select="$OurPrice"/> <br /> <b>List price: </b><xsl:text>$</xsl:text> <xsl:value-of select="$ListPrice"/> <xsl:text> (</xsl:text> <i>that's </i> <b> <xsl:value-of select="100 - round(($OurPrice div $ListPrice) * 100)"/> <xsl:text>%</xsl:text> </b> <i> off!</i> <xsl:text>)</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="SalesRank"> <br /> <b> <xsl:text>Sales rank: </xsl:text> <xsl:value-of select="."/> </b> </xsl:template> <xsl:template match="UsedPrice"> <br /> <b>Used price: </b> <xsl:value-of select="."/> </xsl:template> <xsl:template match="CollectiblePrice"> <br /> <b>Collectible price: </b> <xsl:value-of select="."/> </xsl:template> <xsl:template match="ThirdPartyNewPrice"> <br /> <b>Buy one from zShops for: </b> <xsl:value-of select="."/> </xsl:template> <xsl:template match="Authors"> <xsl:choose> <xsl:when test="count(Author)> 2"> <b>Authors: </b> <xsl:for-each select="Author"> <xsl:choose> <xsl:when test="not(position() = last())"> <xsl:value-of select="."/> <xsl:text>, </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>and </xsl:text> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:when> <xsl:when test="count(Author) = 2"> <b>Authors: </b> <xsl:value-of select="Author[1]"/> <xsl:text> and </xsl:text> <xsl:value-of select="Author[2]"/> </xsl:when> <xsl:otherwise> <b>Author: </b> <xsl:value-of select="Author"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="BuyButton"> <xsl:param name="Asin"/> <xsl:element name="a"> <xsl:attribute name="href" xml:space="default">http://www.amazon.com/o/dt/assoc/handle-buy-box?asin=<xsl:value-of select="$Asin"/>&tag_value=associates_tag&dev-tag-value=D24H52G74BUDRY&submit.add-to-cart=true</xsl:attribute> <xsl:attribute name="target" xml:space="default">_blank</xsl:attribute> <xsl:text>Buy from Amazon.com</xsl:text> </xsl:element> </xsl:template> <xsl:template match="AvgCustomerRating"> <tr> <td colspan="2"> <b>Average customer rating: </b> <xsl:call-template name="Stars"> <xsl:with-param name="average" select="."/> </xsl:call-template> </td> </tr> </xsl:template> <xsl:template match="CustomerReview"> <tr> <td colspan="2"> <xsl:call-template name="Stars"> <xsl:with-param name="average" select="Rating"/> </xsl:call-template> <xsl:text> </xsl:text> <b><xsl:value-of select="Summary"/></b> <br /> <p><xsl:value-of select="Comment"/></p> </td> </tr> </xsl:template> <xsl:template name="Stars"> <xsl:param name="average" select="5"/> <xsl:choose> <xsl:when test="$average > 4.75"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-5-0.gif"/> </xsl:when> <xsl:when test="$average > 4.25"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-4-5.gif"/> </xsl:when> <xsl:when test="$average > 3.75"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-4-0.gif"/> </xsl:when> <xsl:when test="$average > 3.25"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-3-5.gif"/> </xsl:when> <xsl:when test="$average > 2.75"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-3-0.gif"/> </xsl:when> <xsl:when test="$average > 2.25"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-2-5.gif"/> </xsl:when> <xsl:when test="$average > 1.75"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-2-0.gif"/> </xsl:when> <xsl:when test="$average > 1.25"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-1-5.gif"/> </xsl:when> <xsl:when test="$average > .75"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-1-0.gif"/> </xsl:when> <xsl:when test="$average > .25"> <img src="http://g-images.amazon.com/images/G/01/detail/stars-0-5.gif"/> </xsl:when> <xsl:otherwise> <img src="http://g-images.amazon.com/images/G/01/detail/stars-0-0.gif"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> 1.1 xml-cocoon2/src/webapp/samples/webserviceproxy/cocoonhive/amazon/bookInfo2page.xsl Index: bookInfo2page.xsl =================================================================== <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ch="http://cocoonhive.org/portal/schema/2002" > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="ch:menu"> <xsl:copy> <ch:item> <ch:label>Book List</ch:label> <ch:command>page-amazon-listMania</ch:command> </ch:item> <xsl:apply-templates select="./*"/> </xsl:copy> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]