Changes between Version 11 and Version 12 of XsltTemplates
- Timestamp:
- 04/02/11 21:07:55 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
XsltTemplates
v11 v12 1 XSLT and XPath are two key technologies used within SahanaPy to allow easy importing and exporting of information in a wide variety of formats. Support for importing and exporting data is mostly managed via XSLT templates. 1 [[TOC]] 2 = XSLT = 3 XSLT and XPath are two key technologies used within Sahana Eden to allow easy importing and exporting of information in a wide variety of formats. 4 5 Support for importing and exporting data is mostly managed via XSLT templates. 2 6 3 7 == Sahana Data Models == 4 The underlying data models in {{{models/}}} define the resulting structure that will be within <sahanapy>. More technical detail is [http://trac.sahanapy.org/wiki/S3XRC available here].8 The underlying data models in {{{models/}}} define the resulting structure that will be within the XML. 5 9 6 == Sahana XSLT Information == 7 Sahana XSLT/XPath capability is provided by [http://codespeak.net/lxml/ lxml]. Currently Sahana only supports XSLT/XPath 1.0. 10 == XSLT Library == 11 Sahana XSLT/XPath capability is provided by [http://codespeak.net/lxml/ lxml]. Currently lxml only supports XSLT/XPath 1.0. 12 13 A collection of useful reusable functions are stored in {{{static/formats/xml/commons.xsl}}} 8 14 9 15 == Sahana XML Representation == 10 Here is a simplified blank XML document that highlights the key elements providing in the native XML within SahanaPy. 11 {{{ 12 <sahanapy> 13 <resource name="" uuid="" created_on="" modified_on="" url=""> 14 <data field=""></data> 15 <reference field="" resource="" uuid=""></reference> 16 </resource> 17 </sahanapy> 18 }}} 19 * {{{<resource>}}} - identifies the type of resource e.g. {{{name="hms_hospital"}}} 20 * {{{<data>}}} - represents a data field from the model e.g. if a resource is hms_hospital, then the data fields provided will be defined in {{{models/hms.py}}} - look for the resource definition for hospital 21 * {{{<reference>}}} - contains information about things such as location e.g. {{{field="location_id" resource="gis_location"}}} 16 See: [wiki:S3XRC/S3XML] 17 18 There are 2 parameters which are passed in: 19 * name (comes from the resourcename - e.g. 'sehlter') 20 * xsltmode (passed in as a var on the URL - e.g. '&xsltmode=extended') 22 21 23 22 == Exporting Data from Sahana == 24 Sahana export templates are stored in: {{{static/ xslt/export}}}23 Sahana export templates are stored in: {{{static/formats/*/export.xsl}}} 25 24 26 25 == Importing Data from Sahana == 27 Sahana import templates are stored in: {{{static/ xslt/import}}}26 Sahana import templates are stored in: {{{static/formats/*/import.xsl}}} 28 27 29 28 == Background Info and Resources == … … 33 32 * [http://www.w3schools.com/xpath/default.asp XPath Tutorial] on w3schools 34 33 * [http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog interactive xslt environment] 34 35 == Debugging == 36 Debug the stylesheets outside Sahana using Xalan. 37 38 Start by converting smaller extracts in debug mode: 39 {{{ 40 java -jar xalan.jar -param name shelter -param xsltmode extended -tt -tg -ts -in japanquake2011_shelter_extract.kml -xsl web2py\applications\eden\static\formats\kml\import.xsl -out shelters.xml 41 }}} 42 43 Then process the full thing in non-debug mode: 44 {{{ 45 java -jar xalan.jar -param name shelter -param xsltmode extended -in japanquake2011_shelter.kml -xsl web2py\applications\eden\static\formats\kml\import.xsl -out shelters.xml 46 }}} 47 48 For a graphical IDE (Java, so cross-platform), you can trial [http://editix.com EditX] 49 50 ---- 51 DeveloperGuidelines