|Fig. 1. Pagelet Date Formats (note the raw native dates)|
|Fig. 2. Query Date Formats (note the correct formatting)|
So, why the inconsistency in formatting? Well, I think this has to do with the XML document generated as source data for the Pagelet Wizard. One of the issues with this XML is that it contains no field data type declarations. Consequently the Pagelet Wizard XSL cannot distinguish XML element values that are dates from any other type of field. See example XML source data in Fig 3.
|Fig. 3. XMLQuery source data (no field type declarations)|
So, if you want to format dates in your Pagelet results then you can use the same
We first need to write some XSL which will identify the field you want to format. What you write will depend on the method used by the XSL to process the XML. For example if you are using the delivered Bulleted List XSL template then there is an iteration of the XML document using an
construct. This will apply the same XSL to every element in the querdata result set. So to pickout just the date fields we need to test each field. So, add an
<xsl:for-each ...=""> </xsl:for-each>
logic to identify the nth field. An example of this is shown in Fig 4.
<xsl:when ...="" condition="" test="expression"> </xsl:when>
|Fig. 4. Bulleted List iteration of XML querydata|
|Fig. 5. Evaluate fieldname attribute in the querydata element|
- XM formatter - http://www.freeformatter.com/xml-formatter.html
- XML Editing I use Notepad++ (free) or Ultraedit (well worth a few quid)
- XSL debugging - XML/Spy (http://www.altova.com/xml_tools.html) has an excellent debugger (again, well worth the money) It will save you hours!!!
- XSL Transformer online (http://www.freeformatter.com/xsl-transformer.html) . Very handy online XSL transnformer. NOTE: This won't interpret the PSFORMAT tag as this is proprietary to PeopleSoft.
Anyway, back to XSL for Table based layouts in pagelets. You'll find a block of XSL for each column so you won't need to try and work out which field your processing. This makes targeting only the date fields easier. Fig. 6 shows the PSFORMAT tag added into the XSL for table based Pagelet.
|Fig. 6. PSFORMAT added to table based XSL template (note the position()=2 selector)|
Hope you find this helpful and have as much fun with it as I did.