jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-taglibs/xtags/examples/web/test snoop.jsp test_add.jsp test_replace.jsp
Date Tue, 24 Jul 2001 14:29:14 GMT
jstrachan    01/07/24 07:29:14

  Added:       xtags/examples/web nasdaq_quotes.jsp
               xtags/examples/web/test snoop.jsp test_add.jsp
                        test_replace.jsp
  Log:
  Added new examples and test cases
  
  Revision  Changes    Path
  1.1                  jakarta-taglibs/xtags/examples/web/nasdaq_quotes.jsp
  
  Index: nasdaq_quotes.jsp
  ===================================================================
  <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  <html>
  <%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>NASDAQ Quotes</title>
  <link rel="stylesheet" href="examples.css" type="text/css">
  </head>
  <body>
  
  <% 
      String symbols = request.getParameter( "symbols" );
      if ( symbols == null ) {
          symbols = "ORCL+IBM+SUNW";
      }
      else {
          symbols = symbols.replace( ' ', '+' );
      }
      // note this URL should only be used for development!
      String url = "http://www.xmltoday.com/examples/stockquote/getxmlquote.vep?s=" + symbols;
  %>
  
  <p>This example demonstrates fetching XML stock quotes from a web service 
  and formatting the results using the XTags library.</p>
  
  
  
  <h2>Stock Codes</h2>
  
  <form METHOD="GET" ACTION="<%= request.getRequestURI() %>">
  
    Enter symbol(s): 
  
    <input type="text" name="symbols" value="<%= symbols %>"/>
  
    &nbsp;&nbsp;
  
    <input type="submit" value="Get Quotes"/>
  </form>
  
  
  
  <h2>Stock Quotes</h2>
  
  <xtags:parse url="<%= url %>"/>
  
  <table cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
    <tr bgcolor="#dddddd">
      <th>Symbol</th>
      <th align="right">Ask</th>
      <th align="right">Open</th>
      <th align="right">Days High</th>
      <th align="right">Days Low</th>
      <th align="right">Price Change</th>
      <th align="right">Volume</th>
      <th>Date</th>
      <th>Time</th>
    </tr>
  
    <xtags:forEach select="//stock_quote">
      <tr bgcolor="#eeeeee">
        <td>
          <xtags:valueOf select="symbol"/>
        </td>
        <td align="right">
          <xtags:valueOf select="price[@type='ask']/@value"/>
        </td>
        <td align="right">
          <xtags:valueOf select="price[@type='open']/@value"/>
        </td>
        <td align="right">
          <xtags:valueOf select="price[@type='dayhigh']/@value"/>
        </td>
        <td align="right">
          <xtags:valueOf select="price[@type='daylow']/@value"/>
        </td>
        <td align="right">
          <xtags:valueOf select="change"/>
        </td>
        <td align="right">
          <xtags:valueOf select="volume"/>
        </td>
        <td>
          <xtags:valueOf select="when/date"/>
        </td>
        <td>
          <xtags:valueOf select="when/time"/>
        </td>
      </tr>
    </xtags:forEach>
  </table>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/xtags/examples/web/test/snoop.jsp
  
  Index: snoop.jsp
  ===================================================================
  <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  <html>
  <%@ page import="javax.servlet.*" %>
  <%@ page import="javax.servlet.http.*" %>
  <%@ page import="java.util.*" %>
    <head>
      <title>Snoop</title>
    </head>
    <body>
  
      <h2>HttpServletRequest Properties</h2>
  
      <table width="100%" cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
        <tr bgcolor="#dddddd">
          <th>Property</th>
          <th>Value</th>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getAuthType()</td>
          <td><%= request.getAuthType() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getContextPath()</td>
          <td><%= request.getContextPath() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getPathInfo()</td>
          <td><%= request.getPathInfo() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getPathTranslated()</td>
          <td><%= request.getPathTranslated() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getQueryString()</td>
          <td><%= request.getQueryString() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getRequestedSessionId()</td>
          <td><%= request.getRequestedSessionId() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getRequestURI()</td>
          <td><%= request.getRequestURI() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getServletPath()</td>
          <td><%= request.getServletPath() %></td>
        </tr>
      </table>
  
  
      <h2>ServletRequest Properties</h2>
  
      <table width="100%" cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
        <tr bgcolor="#dddddd">
          <th>Property</th>
          <th>Value</th>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getCharacterEncoding()</td>
          <td><%= request.getCharacterEncoding() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getContentType()</td>
          <td><%= request.getContentType() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getLocale()</td>
          <td><%= request.getLocale() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getProtocol()</td>
          <td><%= request.getProtocol() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getRemoteAddr()</td>
          <td><%= request.getRemoteAddr() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getRemoteHost()</td>
          <td><%= request.getRemoteHost() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getScheme()</td>
          <td><%= request.getScheme() %></td>
        </tr>
        <tr bgcolor="#eeeeee">
          <td>getServerName()</td>
          <td><%= request.getServerName() %></td>
        </tr>
      </table>
  
      <h2>HTTP Headers</h2>
  
      <table width="100%" cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
        <tr bgcolor="#dddddd">
          <th>Property</th>
          <th>Value</th>
        </tr>
        <%
          for ( Enumeration enum = request.getHeaderNames(); enum.hasMoreElements(); ) {
            String headerName = (String) enum.nextElement();
        %>
        <tr bgcolor="#eeeeee">
          <td><%= headerName %></td>
          <td><%= request.getHeader( headerName ) %></td>
        </tr>
        <%
          }
        %>
      </table>
  
      <h2>Request Attributes</h2>
  
      <table width="100%" cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
        <tr bgcolor="#dddddd">
          <th>Property</th>
          <th>Value</th>
        </tr>
        <%
          for ( Enumeration enum = request.getAttributeNames(); enum.hasMoreElements(); )
{
            String attributeName = (String) enum.nextElement();
        %>
        <tr bgcolor="#eeeeee">
          <td><%= attributeName %></td>
          <td><%= request.getAttribute( attributeName ) %></td>
        </tr>
        <%
          }
        %>
      </table>
  
  
      <h2>Request Parameters</h2>
  
      <table width="100%" cellspacing="0" cellpadding="2" bgcolor="#000000" border="1">
        <tr bgcolor="#dddddd">
          <th>Property</th>
          <th>Value</th>
        </tr>
        <%
          for ( Enumeration enum = request.getParameterNames(); enum.hasMoreElements(); )
{
            String attributeName = (String) enum.nextElement();
        %>
        <tr bgcolor="#eeeeee">
          <td><%= attributeName %></td>
          <td><%= request.getParameter( attributeName ) %></td>
        </tr>
        <%
          }
        %>
      </table>
  
  
     </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/xtags/examples/web/test/test_add.jsp
  
  Index: test_add.jsp
  ===================================================================
  <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  <html>
  <%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>Test Add Example</title>
  <link rel="stylesheet" href="examples.css" type="text/css">
  </head>
  
  <body>
  
  <h1>Test Add Example</h1>
  
  <p>This demo tests the use of the &lt;xtags:add&gt; tag to add XML fragments
to an XML document.</p>
  
  
  <hr/>
  
  <xtags:parse>
    <a x="1" y="1">
      <b>
        <c d="123" e="456">
          <foo>abcd</foo>
        </c>
      </b>
      <d x="33" y="99">
        <foo>whoo</foo>
        <e x="234" y="4912">
          <foo>def</foo>
        </e>
      </d>
    </a>
  </xtags:parse>
  
  
  <h2>Before Additions</h2>
  
  <xtags:copyOf select="/"/>
  
  <hr/>
  
  
  <h2>After Additions</h2>
  
  
  <xtags:forEach select="//foo">
    <xtags:add>
      <something>to add
          <with even="more">sub nodes and the like</with>
          <empty/>
      </something>
    </xtags:add>
  </xtags:forEach>
  
  <xtags:forEach select="//b">
    <xtags:add>
      Some text
    </xtags:add>
  </xtags:forEach>
  
  <xtags:forEach select="//b">
    <xtags:add>
      <atag/>
      And some text
    </xtags:add>
  </xtags:forEach>
  
  
  <xtags:copyOf select="/"/>
  
  
  <hr/>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-taglibs/xtags/examples/web/test/test_replace.jsp
  
  Index: test_replace.jsp
  ===================================================================
  <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  <html>
  <%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>Test Add Example</title>
  <link rel="stylesheet" href="examples.css" type="text/css">
  </head>
  
  <body>
  
  <h1>Test Replace Example</h1>
  
  <p>This demo tests the use of the &lt;xtags:replace&gt; tag to replace nodes
in an XML document
  with XML fragments.</p>
  
  
  <hr/>
  
  <xtags:parse>
    <a x="1" y="1">
      <b>
        <c d="123" e="456">
          <foo>abcd</foo>
        </c>
      </b>
      <d x="33" y="99">
        <foo>whoo</foo>
        <e x="234" y="4912">
          <foo>def</foo>
        </e>
      </d>
    </a>
  </xtags:parse>
  
  
  <h2>Before Replacements</h2>
  
  <xtags:copyOf select="/"/>
  
  <hr/>
  
  
  <h2>After Replacements</h2>
  
  
  <xtags:forEach select="//foo">
    <xtags:replace>
      <something>which should 
          <with even="more">have replaced all foo elements</with>
          <empty/>
      </something>
    </xtags:replace>
  </xtags:forEach>
  
  
  <xtags:forEach select="//b">
    <xtags:replace>
      Text that replaces a b node
    </xtags:replace>
  </xtags:forEach>
  
  
  <xtags:copyOf select="/"/>
  
  <h2>Replacing a single node with multiple nodes</h2>
  
  <p>Replacing the &lt;empty&gt; nodes:</p>
  <xtags:forEach select="//empty">
    <xtags:replace>
      <full> node </full>
      with text
      <and>another node</and>
    </xtags:replace>
  </xtags:forEach>
  
  <xtags:copyOf select="/"/>
  
  <h2>Replacing the root element</h2>
  
  <xtags:forEach select="/a">
      <xtags:replace>
          <root>A new ro<sdsd/>ot node</root>
      </xtags:replace>
  </xtags:forEach>
  
  <xtags:copyOf select="/"/>
  
  <h2>Replacing the root node</h2>
  
  <xtags:context select="/">
      <xtags:replace>
          <!-- a comment -->
          <root>Another root node</root>
      </xtags:replace>
  </xtags:context>
  
  <xtags:context select="/">
      <xtags:replace><?xml version="1.0"?>
          <!-- a comment -->
          <root>Another root node <foo>with</foo> an <foo>xml</foo>
declaration</root>
      </xtags:replace>
  </xtags:context>
  
  <% try { %>
  <xtags:context select="//foo">
      <xtags:replace><?xml version="1.0"?>
          <!-- a comment -->
          <root>Another root node with an xml declaration</root>
      </xtags:replace>
  </xtags:context>
  <% } catch (JspException e) { %>
          <p>Exception - should say too many context nodes: <pre><%= e.getMessage()
%></pre></p>
  <% } %>
  
  
  <xtags:copyOf select="/"/>
  
  <hr/>
  
  </body>
  </html>
  
  
  

Mime
View raw message