Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 28, 2001XSP Session O’Reilly Enterprise Java Conference 1 XSP Session Sue Spielman President/Consulting Engineer President/Consulting Engineer www.switchbacksoftware.com.

Similar presentations


Presentation on theme: "March 28, 2001XSP Session O’Reilly Enterprise Java Conference 1 XSP Session Sue Spielman President/Consulting Engineer President/Consulting Engineer www.switchbacksoftware.com."— Presentation transcript:

1 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 1 XSP Session Sue Spielman President/Consulting Engineer President/Consulting Engineer www.switchbacksoftware.com sspielman@switchbacksoftware.com

2 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 2 Session Overview XSP OverviewXSP Overview XSP vs. JSPXSP vs. JSP Technologies InvolvedTechnologies Involved Object ModelObject Model Implementation DetailsImplementation Details SamplesSamples QuestionsQuestions

3 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 3 XSP – What Is It? eXtensible Server PageseXtensible Server Pages Component of Cocoon used for building web apps with dynamic XML contentComponent of Cocoon used for building web apps with dynamic XML content Dynamic content is based onDynamic content is based on –Request Parameters –Databases –Remote Server Processes

4 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 4 XSP – Purpose Created to allow web authors to generate dynamic content without forcing them to learn a programming languageCreated to allow web authors to generate dynamic content without forcing them to learn a programming language Promotes a clean division of labor:Promotes a clean division of labor: –Application Developers –Content authors –Presentation designers

5 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 5 XSP vs. JSP Similarities Follows the compiled server pages modelFollows the compiled server pages model Can be parsed and validated by regular XML parsersCan be parsed and validated by regular XML parsers Can be transformed by XSLT processorsCan be transformed by XSLT processors Aim to programming language abstractionAim to programming language abstraction

6 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 6 XSP vs. JSP Differences Output ExposureOutput Exposure –XSP doesn’t have access to the output stream –JSP has access to output stream Page ReadabilityPage 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

7 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 7 X* Technologies Involved XSP – eXtensible Server PagesXSP – eXtensible Server Pages XML – eXtensible Markup LanguageXML – eXtensible Markup Language –Portable Data XSL - Stylesheet language for XMLXSL - Stylesheet language for XML –Includes an XML vocabulary for specifying formatting XSLT – XSL TransformationsXSLT – XSL Transformations –Language for transforming XML documents into other XML documents.

8 March 28, 2001XSP Session O’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)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).Producers – what XSP pages are compiled into (Cocoon Java type). –Similar to the fact that JSPs are compiled into Servlets

9 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 9 Object Model Model from xml.apache.org

10 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 10 Built-in Objects requestsession responseservletContext documentxspGlobal xspNodeStack xspCurrentNod e xspParentNodexspParser Should look familiar to JSP programmers…

11 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 11 XSPUtil Class DOM utility methodsDOM utility methods –cloneNode, toMarkup HTTPHTTP –encodeMarkup, formEncode, formDecode FileFile –pathComponent, fileComponent, baseName, normalizeBaseName, relativeFileName StringString –split, isAlphaNumeric

12 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 12 What is an XSP Page An XSP page is an XML page with the following requirements:An XSP page is an XML page with the following requirements: –A Cocoon processing instruction that invokes the XSP processor –A Cocoon processing instruction that invokes the XSP processor –Document root element must be –Document root element must be –Any language and Taglib declarations as attributes in the tag. Example: –Any language and Taglib declarations as attributes in the tag. Example: –An element and an element.

13 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 13 Sample Minimal XSP <xsp:logic> static private int counter = 0; static private int counter = 0; private synchronized int count() { private synchronized int count() { return counter++; return counter++; } <page> This page has been requested count() times. This page has been requested count() times.

14 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 14 Processing Instruction XML PIs used to forward the document to the right processor or formatter.XML PIs used to forward the document to the right processor or formatter. for processing for processing for formatting for formatting Examples:Examples: – –

15 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 15 Logic Tags encloses developer- supplied program logic. Transcribed verbatim into the generated Cocoon producer encloses developer- supplied program logic. Transcribed verbatim into the generated Cocoon producer evaluates a program expression and substitutes its value as a Text DOM node in the resulting document evaluates a program expression and substitutes its value as a Text DOM node in the resulting document

16 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 16Tagset<xsp:page><xsp:structure> <xsp:include><xsp:content> <xsp:logic><xsp:expr> <xsp:element><xsp:attribute> <xsp:pi>

17 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 17 Scripting Languages XSP designed to support scripting languages other than JavaXSP designed to support scripting languages other than Java In theory, any programming language that has a Java-based interpreter could be used to script XSPIn theory, any programming language that has a Java-based interpreter could be used to script XSP Right now, only JavaRight now, only Java

18 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 18 Sample - Embedded Logic sample.xml Well formed XSP page XSP Stylesheet sample.xsl HTML sample.html

19 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 19 Sample - Included Logicsheet HTML sample.html LogicSheet sample-xsp.xsl sample.xml Stylesheet sample.xsl XSP Transformed XML

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

21 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 21 Additional Resources xml.apache.orgxml.apache.org xml.apache.org/cocoon/wd-xsp.htmlxml.apache.org/cocoon/wd-xsp.html www.w3.org/TR/xsltwww.w3.org/TR/xslt www.w3.org/TR/REC-xmlwww.w3.org/TR/REC-xml

22 March 28, 2001XSP Session O’Reilly Enterprise Java Conference 22Questions<xsp:logic> ? ? ? </xsp:logic><xsp:logic> </xsp:logic>


Download ppt "March 28, 2001XSP Session O’Reilly Enterprise Java Conference 1 XSP Session Sue Spielman President/Consulting Engineer President/Consulting Engineer www.switchbacksoftware.com."

Similar presentations


Ads by Google