Skip to content

Alternate XML output? #16

@jonnio

Description

@jonnio

More of a comment about a potential extension. We load the output into a document database and use XPath to access the data. As the elements have an @Id attribute in them, the XPaths get a bit ugly. To that end, we run the output through the following XSLT which moves the @Id into the element name (when a segment or element). It would be fantastic if element naming was an option so we could stop using the XSLT.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="no"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="segment[@Id]">
        <xsl:element name="{normalize-space(@Id)}">
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="element[@Id]">
        <xsl:element name="{normalize-space(@Id)}">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions