Download presentation
Presentation is loading. Please wait.
Published byAnthony Benson Modified over 9 years ago
1
A Use-Case Driven Approach to the Development of Reusable Stylesheet Modules Terry Brady LexisNexis
2
Problem to Solve n Collaborative XSLT Development n Create useful modules that will operate in multiple data conversions n Multiple Input DTD’s n Multiple Output DTD’s n Team does not consist of schema “experts”
3
Challenge n Xslt containment not as easy as OO containment n Import precedence is trickier than you think! l Construction of the import tree can radically alter the behavior of individual modules n Difficult to validate to multiple targets
4
XSLT Use n Great for conversions n Requires a shift in mind set n Testing capabilities l Full support not there l Or, so counter-intuitive everyone must solve on their own
5
XSLT Modularity n xsl:import l Creates import tree l Import precedence overrides other precedence l Great for named templates n xsl:include l Creates a single logical module l Precedence: n match specificity n priority n Position l Challenge with named templates!
6
Very Contrived Examples n Input DTD’s l article.dtd l instructions.dtd n Output DTD’s l book.dtd l faq.dtd
7
Article n art:article l (in:title, in:section+) n in:title l (#PCDATA|in:emph|meta:edit-by | meta:edit-date)* n in:section l (in:title?, (in:para+ | in:section+)) n in:para l (#PCDATA | in:emph | meta:edit-by | meta:edit-date)* n in:emph l (#PCDATA | meta:edit-by | meta:edit-date)* n meta:edit-by l (#PCDATA) n meta:edit-date l (#PCDATA)
8
Instructions n man:manual l (in:title, (in:section+ | man:step+)) n in:title l (#PCDATA|in:emph | meta:edit-by | meta:edit-date)* n in:section l (in:title?, (in:para+ | in:section+ | man:step+))> n man:step l (man:num, in:para+) n in:para l (#PCDATA | in:emph | meta:edit-by | meta:edit-date)* n in:emph l (#PCDATA | meta:edit-by | meta:edit-date)* n meta:edit-by l (#PCDATA) n meta:edit-date l (#PCDATA) n man:num l (#PCDATA)
9
Book n book:book l (out:label?, out:header, out:section+) n out:header l (#PCDATA|out:italics)* n out:section l (out:label?, out:header?, (out:section | out:para)+) n out:para l (#PCDATA | out:italics)* n out:italics l (#PCDATA) n out:label l (#PCDATA)
10
Faq n faq:faq l (out:label?, out:header, out:section+) n out:header l (#PCDATA|out:italics)* n out:section l (out:label?, out:header?, out:para+) n out:para l (#PCDATA | out:italics)* n out:italics l (#PCDATA) n out:label l (#PCDATA)
11
Modules Needed General (default/meta) title paragraph section step makebook makefaq n default rule, warn on unmapped elements n In:title out:header n in:para & in:emph n in:section out:section n man:step/man:num n root book:book n root faq:faq
12
Module Imports n makebook.xsl imports section.xsl n makefaq.xsl imports section.xsl n para.xsl imports general.xsl n section.xsl imports para.xsl, title.xsl, step.xsl n step.xsl imports para.xsl n title.xsl imports general.xsl
13
Create Use Cases n Only as complex as needed to illustrate one case n Validate understanding before coding
14
Create Contrived Use Cases n Title n Paragraph n Section n Step n Article n Manual
15
Title Use Case Hello
16
Title with Metadata Hello Terry 1/1/2006
17
Create stylesheets n Determine import hierarchy in advance n Call wherever possible to allow the DTD to change n Iteratively test with use cases. n Validate to DTD and schematron as an additional tool.
18
Import Precedence Issue n in:title processed fine by title.xsl n in:para processed fine by para.xsl n When executing the same files with section.xsl l in:para processed fine l In:title processed by default rule
19
Introduce “template files” n Construct the import tree as needed for production n Modular components reference a “template file” via a processing instruction l Inclusion of default rule l Inclusive set of namespace declarations l Testing-specific match rules
20
New import strategy n makebook.xsl imports general.xsl, section.xsl n makefaq.xsl imports general.xsl, section.xsl n section.xsl imports para.xsl, title.xsl, step.xsl l References template.xsl via pi n step.xsl imports para.xsl l References template.xsl via pi n template.xsl imports general.xsl
21
Other Challenges n Validating output of common modules to multiple target DTD’s n Supporting use cases appropriate to a subset of target DTD’s n Viewing results
22
Unit Test Driver Use Case Files Stylesheets Baseline output Source Code Management Runtime Directory Use Case Files Use Case Files Baseline output Baseline output Schematron, & Template DTD
23
Copy Resources to runtime area Source Code Management Use Case Files Stylesheets Baseline output Runtime Directory Use Case Files Use Case Files Baseline output Baseline output Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Schematron, & Template DTD Schematron, & Template DTD
24
Iterate over use case files Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Schematron, & Template DTD
25
Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Use Case File Copy Schematron, & Template DTD This makes it easier to view the input file in a browser that is not catalog aware Copy use case file with fully resolved DTD (if using catalog)
26
Report the validity of use case file Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Schematron, & Template DTD
27
Find each stylesheet referenced by the use case file… Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Schematron, & Template DTD A single use case could serve as input to multiple stylesheets
28
If the stylesheet references a template, compile a new stylesheet. Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Compiled stylesheet Schematron, & Template DTD This is to allow the creation of a custom import tree when testing an individual module
29
If the stylesheet references a schematron file, compile the schematron and perform semantic validation on the use case file. Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Compiled Schematron Compiled stylesheet Schematron, & Template DTD This permits the enforcement of boundary/scope conditions for a styesheet.
30
For each dtd referenced in the use case file or stylesheet, apply the stylesheet to the use case file. Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Output file DTD Schematron, Template, & DTD Compiled stylesheet Set the system identifier of the output file to the referenced DTD. Validate transformation output to all appropriate targets
31
Report on the validity of the output file. Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Output file DTD Schematron, Template, & DTD Compiled stylesheet Set the system identifier of the output file to the referenced DTD.
32
Apply transformation to use case file without referencing an output DTD. Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Output file Schematron, Template, & DTD Compiled stylesheet DTD
33
If a use case file references a schematron, compile the schematron and perform semantic validation on the output file. Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Output file Schematron, Template, & DTD Compiled Schematron
34
If a baseline file exists that matches the output file, perform a comparison of the two files. Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Output file Schematron, Template, & DTD
35
Generate a summary report of test execution Runtime Directory Use Case Files Stylesheets Baseline output Use Case Files Use Case Files Baseline output Baseline output Schematron, Template, & DTD Summary Report
36
Summary Report Error Statistics Use case file hierarchy n Tree Structure n Hypertext to resources n Error messages Input FileOutput File Stylesheet, DTD, Schematron
37
Summary of methodology n System architect defines stylesheet modules n Developer is assigned a module. n Developer creates use case files. n Use cases are reviewed n Developer iteratively creates XSLT module n Stylesheet and output files are reviewed n Output is "baselined“
38
Benefits n Scope is defined for developer n Developer demonstrates understanding immediately n Use case files serve as communication tool n Architect does not simply state constraints. Constraints are enforced n Regression test is built during development
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.