Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Sometimes we just want to display the year:
Finally, there's one more function we will be using, which converts a string so that the initial letter is a capital:
substring($input, 2))”/>
And that's the end of the preliminaries. Now we can get on with some actual template rules.
validated GEDCOM 6.0 file
The root template rule starts by testing to see if the outermost element of the source document is a GEDCOM element. It doesn't just test the name of the element: the sequence type descriptor
schema-element(GEDCOM)
also checks that the type annotation is appropriate. If the user supplies a source document that hasn't been validated, then this test will fail, even if the document is actually valid, and the stylesheet will proceed no further. If this check weren't present here, some strange and difficult-to-diagnose failures could occur later on, because we are relying on the type annotations being present in the input data.
The entire transformation is then wrapped inside an
validation=“strict”
will cause a failure if the outermost element in the result tree isn't defined in some imported schema, or if the result tree isn't valid against that definition. In this case, the intent is to check that the result is valid XHTML.
The outline of the HTML page is produced when we process the selected
Also known as:
This template rule works through the process of generating the output page. Some observations:
I've chosen to use an internal CSS stylesheet to define styling information such as font sizes, and the task of generating this is delegated to the template named
css-style
. This generates fixed output, as follows:
It would have been quite possible, of course, to attach these attributes to the various HTML elements individually, or to incorporate them using XSLT attribute sets, but this way seems cleaner, and shows how XSLT and CSS can complement each other. In fact, it might have been even better to use an external CSS stylesheet, since a user displaying many of these HTML pages would then get more benefit from caching.
The next template displays the parents of the current individual, as hyperlinks:
as= “schema-element(FamilyRec)?”
select= “key(‘family-of-child’, @Id)[1]”/>
as= “schema-element(IndividualRec)?”
select= “key(‘indi’, $parental-family/HusbFath/Link/@Ref)”/>
as= “schema-element(IndividualRec)?”
select= “key(‘indi’, $parental-family/WifeMoth/Link/@Ref)”/>
Father:
Mother: