User:RailML Coord Documentation/code.xsl: Difference between revisions
Jump to navigation
Jump to search
(Created page with "<syntaxhighlight lang=xml> <?xml version = "1.0" encoding = "UTF-8"?> <xsl:stylesheet version = "2.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl...") |
m (Ferri Leberl moved page Code.xsl to User:Ferri Leberl/code.xsl) |
(No difference)
|
Revision as of 16:25, 15 September 2017
<?xml version = "1.0" encoding = "UTF-8"?> <xsl:stylesheet version = "2.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:for-each select="//element()"> <xsl:value-of select="name()"/> <xsl:text>		</xsl:text><!-- Lücke für Kommentar--> <!-- Subschema --> <xsl:choose> <xsl:when test="ancestor::*:infrastructure"> <xsl:text>IS</xsl:text> </xsl:when> <xsl:when test="ancestor::*:infrastructureVisualizations"> <xsl:text>IS</xsl:text> </xsl:when> <xsl:when test="ancestor::*:rollingstock"> <xsl:text>RS</xsl:text> </xsl:when> <xsl:when test="ancestor::*:timetable"> <xsl:text>TT</xsl:text> </xsl:when> <xsl:when test="ancestor::*:interlocking"> <xsl:text>IL</xsl:text> </xsl:when> <xsl:when test="self::*:infrastructure"> <xsl:text>IS</xsl:text> </xsl:when> <xsl:when test="self::*:infrastructureVisualizations"> <xsl:text>IS</xsl:text> </xsl:when> <xsl:when test="self::*:rollingstock"> <xsl:text>RS</xsl:text> </xsl:when> <xsl:when test="self::*:timetable"> <xsl:text>TT</xsl:text> </xsl:when> <xsl:when test="self::*:interlocking"> <xsl:text>IL</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>CO</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>	</xsl:text> <!-- /Subschema --> <xsl:value-of select="name(..)"/><!--parent--> <xsl:text>	</xsl:text> <!-- Direct children: The `*` here in the `select` statement just selects all child elements. This could also be expressed (perhaps more clearly, but also more verbosely) as either of the following: ./* child::* --> <xsl:for-each select="*"> <!-- We put the semicolon before each child's name. That way, if there are no children, we don't have an extraneous semicolon after the parent's name.--> <xsl:text>;</xsl:text> <xsl:value-of select="name()"/> </xsl:for-each> <xsl:text>	</xsl:text> <!-- Attribute --> <xsl:for-each select="@*"> <xsl:text>;</xsl:text> <xsl:value-of select="name()"/> </xsl:for-each> <xsl:text>			</xsl:text><!-- Lücke für Attributkommentare, Pflichtelement und Pflichtattribute --> <!-- /Attribute --> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>