From f6dd1a0b498be0de3e33b4a9663a601e4925d210 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 25 Jul 2008 16:18:21 +0000 Subject: Tweaks via interactive testing. --- docs/tutorials/lxmlgraph/step02.rst | 3 +- .../lxmlgraph/step02/myapp/samplemodel.xml | 2 +- docs/tutorials/lxmlgraph/step03.rst | 47 ++++++++++++++++------ .../lxmlgraph/step03/myapp/samplemodel.xml | 2 +- 4 files changed, 38 insertions(+), 16 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/lxmlgraph/step02.rst b/docs/tutorials/lxmlgraph/step02.rst index a2c24b7a6..94aca07e4 100644 --- a/docs/tutorials/lxmlgraph/step02.rst +++ b/docs/tutorials/lxmlgraph/step02.rst @@ -35,7 +35,8 @@ your package: :language: xml #. Line 2 provides the root of the model as an XML ```` node. - The element name doesn't have to be ````. + The element name doesn't have to be ````. It has a name of + ``site``. #. In lines 3-4, the ```` contains 2 top-level children: a and b. These are provided as an element name ````. This, diff --git a/docs/tutorials/lxmlgraph/step02/myapp/samplemodel.xml b/docs/tutorials/lxmlgraph/step02/myapp/samplemodel.xml index 83678e5e9..bbe474c63 100644 --- a/docs/tutorials/lxmlgraph/step02/myapp/samplemodel.xml +++ b/docs/tutorials/lxmlgraph/step02/myapp/samplemodel.xml @@ -1,5 +1,5 @@ - + diff --git a/docs/tutorials/lxmlgraph/step03.rst b/docs/tutorials/lxmlgraph/step03.rst index 89e62f640..5e7911889 100644 --- a/docs/tutorials/lxmlgraph/step03.rst +++ b/docs/tutorials/lxmlgraph/step03.rst @@ -16,19 +16,29 @@ ZPT Templates ======================== Let's start with a ZPT-based default view for the nodes in the XML. -Add this to your project's ``configure.zcml``: +Change your project's ``configure.zcml`` so that it looks like this: .. code-block:: xml - + -This view stanza indicates that the *default view* for a model that -implements ``lxmlgraph.models.IMyModel`` should be the -``lxmlgraph.views.zpt_view`` function. It is the *default* view because -this stanza does not have a ``name`` attribute. + + + + + + + +In other words, replace the default view function with +``.views.zpt_view``. This view stanza indicates that the *default +view* for a model that implements ``lxmlgraph.models.IMyModel`` should +be the ``lxmlgraph.views.zpt_view`` function. It is the *default* +view because this stanza does not have a ``name`` attribute. Additonally, add a template to your project's ``templates`` directory named ``default.pt`` with this content: @@ -97,9 +107,16 @@ following:: The node has a tag name of: document. +If you visit ``http://localhost:5432/`` you will see:: + + My template is viewing item: site + + The node has a tag name of: site. + We've successfully rendered a view that uses a template against a model using the ZPT templating language. + XSLT Templates ==================== @@ -153,7 +170,8 @@ to your ``views.py`` file: ``xsltview.xsl`` -------------------------------- -How different does the XSLT itself look? At this stage, not too different: +Add a file named ``xsltview.xsl`` to your application's ``templates`` +directory and give it the following contents: .. literalinclude:: step03/myapp/templates/xsltview.xsl :linenos: @@ -176,9 +194,8 @@ How different does the XSLT itself look? At this stage, not too different: Viewing the XSLT -------------------- -With this in place, runnning the application provides a URL such as -``http://localhost:5432/a/xsltview.html``. Going to that URL should -show:: +With those changes in place, restart the application. Visiting to the +``http://localhost:5432/a/xsltview.html`` URL should show:: My template is viewing item: a @@ -186,3 +203,7 @@ show:: We've successfully run an XSL template against our model object. +We've now seen how to use ZPT and XSL templates against model objects +created via an XML tree. + + diff --git a/docs/tutorials/lxmlgraph/step03/myapp/samplemodel.xml b/docs/tutorials/lxmlgraph/step03/myapp/samplemodel.xml index 83678e5e9..bbe474c63 100644 --- a/docs/tutorials/lxmlgraph/step03/myapp/samplemodel.xml +++ b/docs/tutorials/lxmlgraph/step03/myapp/samplemodel.xml @@ -1,5 +1,5 @@ - + -- cgit v1.2.3