1 / 22

XSP Session

Sue Spielman President/Consulting Engineer www.switchbacksoftware.com sspielman@switchbacksoftware.com. XSP Session. Session Overview. XSP Overview XSP vs. JSP Technologies Involved Object Model Implementation Details Samples Questions. XSP – What Is It?. eXtensible Server Pages

maylin
Download Presentation

XSP Session

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sue Spielman President/Consulting Engineer www.switchbacksoftware.com sspielman@switchbacksoftware.com XSP Session XSP SessionO’Reilly Enterprise Java Conference

  2. Session Overview • XSP Overview • XSP vs. JSP • Technologies Involved • Object Model • Implementation Details • Samples • Questions XSP SessionO’Reilly Enterprise Java Conference

  3. XSP – What Is It? • eXtensible Server Pages • Component of Cocoon used for building web apps with dynamic XML content • Dynamic content is based on • Request Parameters • Databases • Remote Server Processes XSP SessionO’Reilly Enterprise Java Conference

  4. XSP – Purpose • Created to allow web authors to generate dynamic content without forcing them to learn a programming language • Promotes a clean division of labor: • Application Developers • Content authors • Presentation designers XSP SessionO’Reilly Enterprise Java Conference

  5. XSP vs. JSP Similarities • Follows the compiled server pages model • Can be parsed and validated by regular XML parsers • Can be transformed by XSLT processors • Aim to programming language abstraction XSP SessionO’Reilly Enterprise Java Conference

  6. XSP vs. JSP Differences • Output Exposure • XSP doesn’t have access to the output stream • JSP has access to output stream • Page Readability • XSP uses the XML features to allows code to be easily distinguishable between markup elements • JSP needs to enclose programming code by scriptlet tags XSP SessionO’Reilly Enterprise Java Conference

  7. X* Technologies Involved • XSP – eXtensible Server Pages • XML – eXtensible Markup Language • Portable Data • XSL - Stylesheet language for XML • Includes an XML vocabulary for specifying formatting • XSLT – XSL Transformations • Language for transforming XML documents into other XML documents. XSP SessionO’Reilly Enterprise Java Conference

  8. Object Model • Processors – take a DOM tree as input and produce another DOM tree as output (i.e. XSP engine in Cocoon) • Producers – what XSP pages are compiled into (Cocoon Java type). • Similar to the fact that JSPs are compiled into Servlets XSP SessionO’Reilly Enterprise Java Conference

  9. Object Model Model from xml.apache.org XSP SessionO’Reilly Enterprise Java Conference

  10. Built-in Objects Should look familiar to JSP programmers… XSP SessionO’Reilly Enterprise Java Conference

  11. XSPUtil Class • DOM utility methods • cloneNode, toMarkup • HTTP • encodeMarkup, formEncode, formDecode • File • pathComponent, fileComponent, baseName, normalizeBaseName, relativeFileName • String • split, isAlphaNumeric XSP SessionO’Reilly Enterprise Java Conference

  12. What is an XSP Page • An XSP page is an XML page with the following requirements: • A Cocoon processing instruction that invokes the XSP processor <?cocoon processtype="xsp"?> • Document root element must be <xsp:page> • Any language and Taglib declarations as attributes in the <xsp:page> tag .Example: <xsp:page language="java“ xmlns:xsp="http://www.apache.org/1999/XSP/Core"> • An <xsp:logic> element and an <xsp:exp> element. XSP SessionO’Reilly Enterprise Java Conference

  13. Sample Minimal XSP <?xml version="1.0"?> <?cocoon-process type="xsp"?> <?cocoon-process type="xslt"?> <?xml-stylesheet href="page-html.xsl" type="text/xsl"?> <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"> <xsp:logic> static private int counter = 0;  private synchronized int count() { return counter++; } </xsp:logic> <page> <p>This page has been requested <xsp:expr>count()</xsp:expr> times.</p> </page> </xsp:page> XSP SessionO’Reilly Enterprise Java Conference

  14. Processing Instruction • XML PIs used to forward the document to the right processor or formatter. • <?cocoon-process type="xxx"?> for processing • <?cocoon-format type="yyy"?> for formatting • Examples: • <?cocoon-process type="xsp"?> • <?cocoon-process type="xslt"?><?xml-stylesheet href="sample.xsl” type="text/xsl"?> XSP SessionO’Reilly Enterprise Java Conference

  15. Logic Tags • <xsp:logic> encloses developer-supplied program logic. Transcribed verbatim into the generated Cocoon producer • <xsp:expr> evaluates a program expression and substitutes its value as a Text DOM node in the resulting document XSP SessionO’Reilly Enterprise Java Conference

  16. Tagset XSP SessionO’Reilly Enterprise Java Conference

  17. Scripting Languages • XSP designed to support scripting languages other than Java • In theory, any programming language that has a Java-based interpreter could be used to script XSP • Right now, only Java XSP SessionO’Reilly Enterprise Java Conference

  18. Sample - Embedded Logic sample.xml sample.xsl Well formed XSP page Stylesheet sample.html HTML XSP XSP SessionO’Reilly Enterprise Java Conference

  19. Sample - Included Logicsheet sample-xsp.xsl LogicSheet sample.xsl Stylesheet sample.html HTML sample.xml XML XSP Transformed XML XSP SessionO’Reilly Enterprise Java Conference

  20. Sample - Taglib Logicsheet Cocoon properties taglib.xsl Properties File LogicSheet sample.xsl Stylesheet sample.html HTML sample.xml XSP That Includes A Reference To A Taglib XSP Transformed XML XSP SessionO’Reilly Enterprise Java Conference

  21. Additional Resources • xml.apache.org • xml.apache.org/cocoon/wd-xsp.html • www.w3.org/TR/xslt • www.w3.org/TR/REC-xml XSP SessionO’Reilly Enterprise Java Conference

  22. Questions <xsp:logic> ? ? ? </xsp:logic> XSP SessionO’Reilly Enterprise Java Conference

More Related