Reputation: 1
I'm using the XSLT v3 capability to transform json to XML. Assuming I get the resulting standard transformation injected into an XML "metadata" node, I'd like to render the information in html using XSLT. How do I recurse the map elements to isolate the individual object name "MyClass" and it's properties - "myName", "myAddress", and their associated types - "string", "number" etc...
<metadata>
<map xmlns="http://www.w3.org/2005/xpath-functions">
<string key="type">object</string>
<map key="properties">
<map key="MyClass">
<string key="type">array</string>
<map key="items">
<string key="type">object</string>
<map key="properties">
<map key="myName">
<string key="type">string</string>
</map>
<map key="myAddress">
<string key="type">string</string>
</map>
<map key="myAge">
<string key="type"number</string>
</map>
</map>
</map>
</map>
</map>
</map>
</map>
</metadata>
Upvotes: 0
Views: 33
Reputation: 163595
It depends very much what HTML output you want to produce. You could do it, for example, using
<xsl:template match="fn:string">
<p>{string-join(ancestor-or-self::*/@key, '/')} = {.}</p>
<xsl:apply-templates/>
</xsl:template>
Recursive descent of the input document using xsl:apply-templates
is very much the normal way of processing in XSLT, whether the input data is actually recursive or not.
Upvotes: 0