Sakai09 Osp Preconference Afternoon Forms

658 views

Published on

Boston Sakai09 Preconference workshop on OSP forms. We cover XML, XSD, XSL basics and specifics as it pertains to OSP. There is a packet of downloadable support files for the workshop at:

http://threecanoes.com/2009-boston-workshop

This presentation is distributed under the Creative Commons "Attribution Non-Commercial No Derivatives" license.

Please post questions about the materials on these presentations to the Sakai portfolio list.

Published in: Business, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
658
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Explore a form Data XML document
  • Sakai09 Osp Preconference Afternoon Forms

    1. 1. OSP Preconference Workshop:OSP Form Schemas and Renderers<br />Janice Smith, Education Consultant, Three Canoes<br />Sean Keesler, Education Consultant, Three Canoes<br />
    2. 2. Objectives<br />Understand the XML technology stack (XML, XSD, XSL)<br />Understand the role of XSD and XSL in OSP forms<br />Understand how to manipulate form schema in an XML IDE<br />Be able to capture the stored XML from an OSP form<br />Be able to change a form’s appearance through form schema and XSL renderers<br />July 2009<br />2<br />10th Sakai Conference - Boston, MA, U.S.A.<br />
    3. 3. Form Design and Use<br />
    4. 4. The XML Technology Stack<br />A little background…<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />4<br />
    5. 5. XML<br />A “Correct” XML document is a text file that is:<br />Well formed <br />Opening and closing tags that do not overlap<br />Optionally validated against a set of rules<br />DTD and XML Schema<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />5<br />
    6. 6. Parts of a Form XML document<br />File MetaData<br />File ID and Display Name<br />Created and modified dates<br />Structured Data<br />The form data for each field<br />Schema information<br />Instructions and validation rules<br />CSS information for styling<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />6<br />
    7. 7. Explore Form XML in Oxygen IDE<br />You do it!<br />Open “sampleFormXML.xml”<br />Identify the parts of the XML document<br />Identify what fields were filled out<br />Identify the form instructions when this form was completed<br />Use OxygenXML to identify the set of elements in the XML to get the “displayName” of this file<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />7<br />
    8. 8. XPATH<br />Expressions that are used by many technologies (including XSLT) to specify one or more parts of an XML document (a node set) that meet a set of conditions<br />Can be an absolute path:<br />/formView/formData/artifact/metaData/repositoryNode/created<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />8<br />
    9. 9. XPATH<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />9<br />Can be an absolute path:<br />/formView/formData/artifact/metaData/repositoryNode/created<br />… refers to:<br />“&lt;created&gt;Thu Jul 02 17:03:00 UTC 2009&lt;/created&gt;”<br />
    10. 10. XPATH<br />Can be a relative PATH: ../../displayName<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />10<br />…refers to “&lt;displayName&gt;Test Feedback&lt;/displayName&gt;”<br />if used from the “created” element<br />
    11. 11. XPATH<br />Can include conditions in “predicates”//element[@name=‘value’]/<br />…refers to all “element” node sets that have their “name” attribute set to “value”<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />11<br />
    12. 12. Finding an XPATH with OxygenXML<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />12<br />XPATH expressions can be generated and tested by using the XPATH functionality in Oxygen<br />
    13. 13. XPATH<br />You do it!<br />Find the XPATH to the &lt;displayName&gt; element of the formView XML<br />Generate an XPATH expression that will refer to the “value” field in the form’s structured data<br />Generate an XPATH expression that will refer to the last date the form data was modified <br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />13<br />
    14. 14. What is an XML Schema?<br />An XML document<br />Describes other XML data files<br />Structure<br />Data types<br />Data validation rules<br />Provides a means to “validate” another XML document<br />14<br />
    15. 15. XSD Example<br />Form requirements:<br />3 fields<br />Evaluation – Numeric value from 0 – 3<br />“Short” Rich text field – 1200 characters max<br />Rich text field – “no limit”<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />15<br />
    16. 16. XSD Example<br />One way to represent the “Value” field<br /> &lt;xs:element name=&quot;value&quot;&gt;<br /> &lt;xs:simpleType&gt;<br /> &lt;xs:restriction base=&quot;xs:integer&quot;&gt;<br /> &lt;xs:minInclusive value=&quot;0&quot;/&gt;<br /> &lt;xs:maxInclusive value=&quot;3”/&gt;<br /> &lt;/xs:restriction&gt;<br /> &lt;/xs:simpleType&gt;<br /> &lt;/xs:element&gt;<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />16<br />
    17. 17. XSD in OSP<br />XSD describes “valid” data<br /> AND<br />Provides information to form presentation tool about how to render the HTML form<br />Uses “ospi” extensions<br />Form field labels and descriptive text <br />Use of rich text editor<br />“Subform keys”<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />17<br />
    18. 18. XSD in OSP Examples<br />This XSD snippet:<br />&lt;xs:element name=&quot;value&quot; minOccurs=&quot;0&quot;&gt;<br />&lt;xs:annotation&gt;<br /> &lt;xs:documentation source=&quot;ospi.label&quot;&gt;Evaluation <br /> &lt;/xs:documentation&gt;<br />&lt;/xs:annotation&gt;<br />&lt;xs:simpleType&gt;<br />&lt;xs:restriction base=&quot;xs:string&quot;&gt;<br />&lt;xs:enumeration value=&quot;3&quot;&gt;&lt;/xs:enumeration&gt;<br />&lt;xs:enumeration value=&quot;2&quot;&gt;&lt;/xs:enumeration&gt;<br />&lt;xs:enumeration value=&quot;1&quot;&gt;&lt;/xs:enumeration&gt;<br />&lt;xs:enumeration value=&quot;0&quot;&gt;&lt;/xs:enumeration&gt;<br />&lt;/xs:restriction&gt;<br />&lt;/xs:simpleType&gt;<br />&lt;/xs:element&gt;<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />18<br />Produces this HTML form field:<br />
    19. 19. Explore XSD in OSP<br />You do it!<br />Open “schemaEnumeratedTextValue.xsd”<br />Identify the form elements and validation rules<br />Change the “value” scale to include 5 values<br />Reorder the fields so that the “value” field is last on the form<br />Make the “value” a required field<br />Add a new field that prompts user for an evaluation date of the type “xs:date”<br />Create a new form with this new schema and see the results by “Previewing” the form.<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />19<br />
    20. 20. Questions about:<br />XML<br />XSD<br />XPATH<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />20<br />
    21. 21. Form RenderINGLogic<br />
    22. 22. An XSL Primer<br />An XML document can be “transformed” into a new XML document by a set of instructions written in XSLT (Extensible Stylesheet Language Transformation)<br />Sakai includesXalanJ - an XSLT processor<br />
    23. 23. A “passthrough” XSL file<br />Instructs the XSL processor to send a copy of the input as its output.<br />Useful because we have no way to see the raw XML “behind the scenes” that we want to transform.<br />Included in handouts as “passthrough.xsl”<br />23<br />
    24. 24. Passthrough XSL<br />Note the use of the XPATH expression in the match attribute<br />Specifies we are taking a “copy-of” everything below the “root element”<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />24<br />
    25. 25. Form Rendering XSL<br />When Sakai renders a form, it assembles an XML document behind the scenes.<br />Form XML is rendered using the default renderers (formCreate.xslt/formFieldTemplate.xslt) or your custom renderers.<br />Use a “passthrough” xsl as a custom renderer to capture the raw form XML<br />Use that as your XML input in an XML IDE to create your own form renderers.<br />
    26. 26. Capture “Raw” form XML <br />You do it!<br />Create a form using the the “practice” schema in your handouts. Upload the passthrough XSL file to resources and use it as a form view renderer for this form.<br />Fill the form out in resources.<br />Click on the form name in resources<br />Capture the form XML (you need to “view source” since it isn’t HTML).<br />Copy and paste it into a new XML document in Oxygen<br />Use Oxygen “Format and Indent” ( ) feature to format the file.<br />Save the file as “formPassthrough.xml”<br />26<br />
    27. 27. “Import” Rather than “Include”<br />The default formCreate.xslt renderer “includes” the formFieldTemplatestylesheet.<br />If you want fields to be rendered differently than the defaults, import formFieldTemplate.xslt and override form field templates locally.<br />Use “customFormCreate.xslt” from the handouts<br />27<br />
    28. 28. Oxygen and XSL<br />Oxygen is shipped with XalanJ<br />“Transformation Scenarios” can be established to transform one XML document with an XSL stylesheet<br />Allows for quicker iterative development than repeatedly uploading your XSL stylesheets into Sakai <br />28<br />
    29. 29. Configure Transformation Scenario<br />Start with the document you wish to transform<br />Establish a new project scenario<br />Inputs<br />XML URL: ${currentFileURL} (the default)<br />XSL URL: browse to locate your new stylesheet<br />Transformer: Xalan<br />Extensions: add the xslt-façade.jar (in handouts)<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />29<br />
    30. 30. Configure a Transformation Scenario<br />Outputs:<br />Save As: “out.html”<br />“Open in Browser” and “Saved File”: if you want to view it in a browser<br />“Open in Editor” to view the XML output<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />30<br />
    31. 31. Create a Custom Form Renderer<br />Watch me! <br />Using the “practice” form from earlier<br />Set up a scenario with the raw XML and the “formCustomCreate.xslt” in the handouts<br />Add a prompt for the “shortText” field and view the results of a transformation.<br />Switch the “import” of the formFieldTemplate to import from Sakai rather than your desktop.<br />Upload the file and attach it as your custom renderer for this form.<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />31<br />
    32. 32. Create a Custom Form Renderer<br />You do it! <br />Using the “practice” form from earlier<br />Set up a scenario with the raw XML and the “formCustomCreate.xslt” in the handouts<br />Add prompts for the “description” and “value” fields only and view the results of a transformation<br />Change their order and transform it.<br />Add descriptive text somewhere on the form about the meaning of each “value” and transform it.<br />Upload the new renderer and attach it as your custom renderer for this form.<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />32<br />
    33. 33. Other Ideas for Renderers<br />Adding your own CSS files to change the look of a form<br />Attachment of custom JavaScript files to change the form behavior<br />Addition of “default” text to form fields<br />Others?<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />33<br />
    34. 34. Questions about:<br />OxygenXML<br />XSL<br />Form rendering process<br />Form renderers<br />July 2009<br />10th Sakai Conference - Boston, MA, U.S.A.<br />34<br />

    ×