DesignProjectX

Journal

2009-05-20

XML Output and the Debug Page

Posted 2009-05-20 in Technology | XSL | XML | Text

Once the sections have been set up and the data sources have been configured in Symphony, XML output can be attached to a page to be processed using the XSLT page template specified in the Body field of the page configuration. The result document can be XML, HTML or text.

The purpose of configuring data sources is to produce the XML output that XSLT page templates can process to create XML, HTML or text to render to the browser. For Symphony, the goal is usually to produce HTML. The smaller the XML data source, the faster it is to build the XML, the sooner the processor can render the HTML and serve the page to the browser. So, it is important to optimize the XML output to include only what is necessary to build the page. The options to filter, sort, limit and paginate the data sources provide several options to optimize the performance of the site. Symphony provides a means of being able to view the XSLT Page Parameters, the XML data, and to analyze performance data by providing debug information in the browser.

If an admin user or Author is logged in to the Symphony admin, front end pages are given the ability to display debug information. Simply add ?debug to the page URL to view Page Parameters, XML Output, XSLT page templates and utilities, Result and Profile data. Refer to the documentation for more information.

Page Parameters

The following page parameters are available for use in XSLT page templates to provide information about the current date and time, the selected page, path and URL, and other details about the site and user data.

  • $today
  • $current-time
  • $this-year
  • $this-month
  • $this-day
  • $timezone
  • $website-name
  • $page-title
  • $root
  • $workspace
  • $root-page
  • $current-page
  • $current-page-id
  • $current-path
  • $parent-path
  • $current-url
  • $upload-limit
  • $symphony-build
  • $entry
  • $cookie-username
  • $cookie-pass

Custom data source parameters, created when specifying Parameter Output Options for data sources, are added at the bottom of the list. For example, when I created the Section data source, I configured the Parameter Output to use the System ID field. This custom data source parameter will appear at the bottom of the list of parameters in the parameter pool.

  • $ds-section

By filtering this data source to include only those entries where the Title field matched the $current-page parameter, I ensure that the Data Source Parameter for the Section data source will output a single ID number. I can then use this ID number to filter other data sources.

Global Parameter Loader Extension

Using the Global Parameter Loader extension, it is possible to add sets of parameters to Symphony’s parameter pool while excluding specified pages. Parameter values can be created by valid PHP code.

XML

The XML output is built by Symphony from the data sources attached to a page. Symphony queries the MySQL database and builds the XML with data as the root node. Each section is added as a child node of the data node with an element name equal to the url-encoded string value of the section label. Each section entry is included as a child of the section node with the element name entry and an id attribute indicating the System ID. Each entry node has a child node for every field specified as Included Elements in the data source configuration. Fields with the possibility of multiple values will contain item nodes for each value.

Example XML Output

The XML for this test entry looks like this:

                      <?xml version="1.0" encoding="utf-8" ?>
<data>
    <events />
    <categories>
        <section id="3" handle="categories">Categories</section>
        <entry id="11" entries="0" items="0">
            <title handle="applications">Applications</title>
        </entry>
        <entry id="12" entries="0" items="0">
            <title handle="design">Design</title>
        </entry>
        <entry id="13" entries="0" items="0">
            <title handle="history">History</title>
        </entry>
        <entry id="14" entries="0" items="0">
            <title handle="ideas">Ideas</title>
        </entry>
        <entry id="15" entries="20" items="0">
            <title handle="technology">Technology</title>
        </entry>
    </categories>
    <entries>
        <pagination total-entries="21" total-pages="1" entries-per-page="50" current-page="1" />
        <section id="4" handle="entries">Entries</section>
        <entry id="40" items="0">
            <title handle="xml-output-and-the-debug-page">XML Output and the Debug Page</title>
            <description word-count="50"><p>Once the sections have been set up and the data sources have been configured in Symphony, XML output can be attached to a page to be processed using the XSLT page template specified in the Body field of the page configuration. The result document can be XML, HTML or text.</p></description>
            <section>
                <item handle="tutorials" id="37">Tutorials</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="20:31" weekday="3">2009-05-20</date>
            <tags>
                <item handle="symphony-cms">symphony cms</item>
                <item handle="xslt">xslt</item>
            </tags>
        </entry>
        <entry id="39" items="0">
            <title handle="symphony-data-sources">Symphony Data Sources</title>
            <description word-count="43"><p>Once the sections have been set up in Symphony, data sources can be configured to output XML that can be used by the XSLT page templates to output HTML pages. These are the data sources that have been used to create this site.</p></description>
            <section>
                <item handle="tutorials" id="37">Tutorials</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="14:47" weekday="3">2009-05-20</date>
            <tags>
                <item handle="symphony-cms">symphony cms</item>
            </tags>
        </entry>
        <entry id="38" items="0">
            <title handle="symphony-sections">Symphony Sections</title>
            <description word-count="45"><p>In Symphony, creating Sections is a way of dynamically creating the database structure for your site and the navigation system of the Symphony admin area. This tutorial assumes that you have installed the integration branch of Symphony 2.0.2 from Github (although, this is not essential).</p></description>
            <section>
                <item handle="tutorials" id="37">Tutorials</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="09:45" weekday="3">2009-05-20</date>
            <tags>
                <item handle="symphony-cms">symphony cms</item>
            </tags>
        </entry>
        <entry id="36" items="0">
            <title handle="beyond-hello-an-xslt-page-template">Beyond Hello: An XSLT Page Template</title>
            <description word-count="43"><p>I started with the basic <a href="http://www.designprojectx.com/tutorials/hello-world-a-basic-xsl-stylesheet/">Hello World</a> example. This tutorial assumes that <a href="http://www.designprojectx.com/tutorials/symphony-sections/">sections</a> have been created in Symphony and <a href="http://www.designprojectx.com/tutorials/symphony-data-sources/">data sources</a> attached to a page. This example shows how I developed the page template that displays the entries that you are currently reading.</p></description>
            <section>
                <item handle="tutorials" id="37">Tutorials</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="08:14" weekday="3">2009-05-20</date>
            <tags>
                <item handle="symphony-cms">symphony cms</item>
                <item handle="xslt">xslt</item>
            </tags>
        </entry>
        <entry id="35" items="0">
            <title handle="xslt-glossary">XSLT Glossary</title>
            <description word-count="47"><p><a href="http://symphony-cms.com/members/TheJester12/">Jesse Sutherland</a> raised some questions about <a href="http://symphony-cms.com/forum/discussions/21437/">learning symphony</a> on the Symphony forum. It seems to be a good time to further develop the documentation and add some tutorials to help beginners get acquainted with the system. A glossary of terms might be a good place to start.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="07:53" weekday="3">2009-05-20</date>
            <tags>
                <item handle="xslt">xslt</item>
            </tags>
        </entry>
        <entry id="34" items="0">
            <title handle="viewing-entries-as-xml">Viewing Entries as XML</title>
            <description word-count="47"><p>To make the process of saving XML files of each entry a little easier, I thought I could create an XSL stylesheet that would output the XML of a single entry. I ended up using Marc Liyanage&#8217;s XML Pretty Printer template to create nicely indented XML files.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="08:59" weekday="1">2009-05-18</date>
            <tags>
                <item handle="xslt">xslt</item>
            </tags>
        </entry>
        <entry id="33" items="0">
            <title handle="symphony-utilities">Symphony Utilities</title>
            <description word-count="30"><p>Utilities are XSLT templates that can be used for a number of different applications. XML can be transformed into text, html, or xml, so the applications can be virtually limitless.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="17:48" weekday="7">2009-05-17</date>
            <tags>
                <item handle="symphony-cms">symphony cms</item>
            </tags>
        </entry>
        <entry id="27" items="0">
            <title handle="maintaining-a-simple-backup-system-in-symphony">Maintaining a Simple Backup System in Symphony</title>
            <description word-count="48"><p>I want to be able to have easy access to all my site content. I also want to be able to write the content in a text editor so that I can use the features that help the writing process go a lot smoother, such as multiple undos.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="08:18" weekday="7">2009-05-17</date>
        </entry>
        <entry id="23" items="0">
            <title handle="symphony-extensions">Symphony Extensions</title>
            <description word-count="49"><p>To get the most out of Symphony, we&#8217;re going to need to extend the core system using extensions. Out of the box, Symphony provides some very powerful features. But it assumes nothing about the type of site that we create. To extend the system, let&#8217;s explore the available extensions.</p></description>
            <section>
                <item handle="tutorials" id="37">Tutorials</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="13:46" weekday="6">2009-05-16</date>
            <tags>
                <item handle="extensions">extensions</item>
                <item handle="symphony-cms">symphony cms</item>
            </tags>
        </entry>
        <entry id="21" items="0">
            <title handle="spreading-myself-too-thin">Spreading Myself Too Thin</title>
            <description word-count="23"><p>So, I&#8217;ve got failed, half-finished, barely started web development / social media experiments scattered all over the web. Let&#8217;s see if I can remember:</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="11:19" weekday="6">2009-05-16</date>
        </entry>
        <entry id="20" items="0">
            <title handle="under-construction">Under Construction</title>
            <description word-count="9"><p>Continuing with my live build of a Symphony site</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="09:40" weekday="6">2009-05-16</date>
        </entry>
        <entry id="19" items="0">
            <title handle="rapid-interactive-prototyping">Rapid Interactive Prototyping</title>
            <description word-count="36"><p>I credit Andy Clarke with the idea of improving the approach of working with wireframes by using the Grey Box Method. I highly recommend his book, Trancending CSS, for both the fantastic content and beautiful design.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="08:46" weekday="4">2009-05-07</date>
        </entry>
        <entry id="5" items="0">
            <title handle="building-a-blog-with-symphony">Building a Blog with Symphony</title>
            <description word-count="14"><p>A step-by-step tutorial to build a blog with XML and XSLT, using Symphony CMS</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="14:33" weekday="3">2009-05-06</date>
        </entry>
        <entry id="29" items="0">
            <title handle="hello-world-a-basic-xsl-stylesheet">Hello World: A Basic XSL Stylesheet</title>
            <description word-count="19"><p>Developing a site with Symphony CMS starts with a basic XSL stylesheet. This is the traditional &#8220;Hello, world&#8221; example.</p></description>
            <section>
                <item handle="tutorials" id="37">Tutorials</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="18:00" weekday="2">2009-05-05</date>
            <tags>
                <item handle="symphony-cms">symphony cms</item>
            </tags>
        </entry>
        <entry id="31" items="0">
            <title handle="fluid-960-grid-system">Fluid 960 Grid System</title>
            <description word-count="44"><p>Nathan Smith created the <a href="http://960.gs/">960 Grid System</a> as a CSS framework that provides classes to easily create web pages that can be designed with a 12-column or 16-column grid. I decided to extend his grids as the <a href="http://www.designinfluences.com/fluid960gs/">Fluid 960 Grid System</a> for fluid layouts.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="16:07" weekday="2">2009-05-05</date>
            <tags>
                <item handle="960-grid-system">960 grid system</item>
                <item handle="css">css</item>
                <item handle="framework">framework</item>
            </tags>
        </entry>
        <entry id="22" items="0">
            <title handle="creating-a-data-structure-in-symphony">Creating a Data Structure in Symphony</title>
            <description word-count="54"><p>Symphony CMS allows the developer the freedom to create a data structure that suits the content of the site. I won&#8217;t be straying far from the usual, to demonstrate the basics. We can always extend these data structures at any time, although, it&#8217;s better to have a clear idea in mind at the outset.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="15:00" weekday="2">2009-05-05</date>
            <tags>
                <item handle="symphony-cms">symphony cms</item>
            </tags>
        </entry>
        <entry id="28" items="0">
            <title handle="the-title-of-my-entry">The Title of My Entry</title>
            <description word-count="6"><p>A brief description of my entry.</p></description>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <date time="09:00" weekday="2">2009-05-05</date>
        </entry>
        <entry id="32" items="0">
            <title handle="lets-get-started-again">Let's Get Started ... Again</title>
            <description word-count="41"><h4>Then, let&#8217;s see if I can finish</h4>
<p>The thing is, when is something really finished on the web? The web is fluid. It is constantly evolving. There&#8217;s always more to learn. So, I think &#8220;finished&#8221; will always be an elusive goal.</p></description>
            <section>
                <item handle="about" id="16">About</item>
            </section>
            <date time="13:00" weekday="1">2009-05-04</date>
        </entry>
        <entry id="25" items="0">
            <title handle="this-looks-broken">This Looks Broken</title>
            <description word-count="14"><h4>Expect things to be broken here.</h4>
<p>I would be surprised if they are not.</p></description>
            <section>
                <item handle="about" id="16">About</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="08:00" weekday="1">2009-05-04</date>
        </entry>
        <entry id="24" items="0">
            <title handle="what-is-this">What is this?</title>
            <description word-count="35"><h4>It is a live build of Symphony</h4>
<p>It started out as a <a href="http://designprojectx.com/about/">live build of a Symphony site</a> during <a href="http://aneventapart.com/2009/seattle/">An Event Apart</a>, while listening to Jeffrey Zeldman and Eric Meyer, and many other fascinating people.</p></description>
            <section>
                <item handle="about" id="16">About</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="00:00" weekday="1">2009-05-04</date>
            <tags>
                <item handle="an-event-apart">an event apart</item>
                <item handle="symphony-cms">symphony cms</item>
            </tags>
        </entry>
        <entry id="26" items="0">
            <title handle="design-project-x">Design Project X</title>
            <description word-count="33"><h4>A site about learning by doing</h4>
<p>This is my playground, my sandbox for projects that I am toying with. I learn by doing. So this is where I do some of my stuff.</p></description>
            <section>
                <item handle="home" id="4">Home</item>
            </section>
            <category>
                <item handle="technology" id="15">Technology</item>
            </category>
            <date time="09:00" weekday="5">2009-05-01</date>
        </entry>
    </entries>
    <entry>
        <pagination total-entries="1" total-pages="1" entries-per-page="20" current-page="1" />
        <section id="4" handle="entries">Entries</section>
        <entry id="28" items="0">
            <title handle="the-title-of-my-entry">The Title of My Entry</title>
            <description word-count="6"><p>A brief description of my entry.</p></description>
            <body word-count="20"><p>This is the body of my entry, using <a href="http://daringfireball.net/projects/markdown/">Markdown</a> to format the text as HTML, using the Symphony Markdown extension.</p></body>
            <section>
                <item handle="journal" id="17">Journal</item>
            </section>
            <date time="09:00" weekday="2">2009-05-05</date>
            <publish>Yes</publish>
        </entry>
    </entry>
    <navigation>
        <page handle="home">
            <name>Home</name>
            <types>
                <type>index</type>
            </types>
        </page>
        <page handle="journal">
            <name>Journal</name>
            <page handle="xml">
                <name>XML</name>
                <types>
                    <type>XML</type>
                </types>
            </page>
            <page handle="text">
                <name>Text</name>
                <types>
                    <type>text</type>
                </types>
            </page>
        </page>
        <page handle="tutorials">
            <name>Tutorials</name>
            <page handle="examples">
                <name>Examples</name>
                <page handle="hello">
                    <name>Hello</name>
                </page>
            </page>
        </page>
        <page handle="about">
            <name>About</name>
        </page>
    </navigation>
    <section>
        <section id="2" handle="sections">Sections</section>
        <entry id="17" entries="12" sections="0" categories="0">
            <title handle="journal">Journal</title>
            <description word-count="0" />
            <body word-count="0" />
            <menu>
                <item handle="content">Content</item>
            </menu>
        </entry>
    </section>
    <types>
        <section id="1" handle="types">Types</section>
        <entry id="6" items="0">
            <title handle="bookmarks">Bookmarks</title>
        </entry>
        <entry id="7" items="0">
            <title handle="books">Books</title>
        </entry>
        <entry id="8" items="0">
            <title handle="files">Files</title>
        </entry>
        <entry id="9" items="0">
            <title handle="photos">Photos</title>
        </entry>
        <entry id="10" items="0">
            <title handle="sites">Sites</title>
        </entry>
    </types>
</data>

                    

Using XPath, the values of each element, attribute, and text node can be processed using the XSLT page template to be copied, transformed and output to the result document.

DesignProjectX | The digital sandbox of Stephen Bau