Subject: Re: [xsl] A use-case for xsl:merge? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 15 Feb 2019 20:21:07 -0000 |
The element prototypes can be in the same document or different documents, but for the purposes of the XSLT3 we are only concerned with merging the external references, such that we have a fully dereferenced (i.e. standalone) XML instance.
I already have code to pull in the external references (prototypes) and run the XPath (via evaluate) on them. I've put all the code on GitHub to hopefully make this easier to understand.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math" version="3.0">
<xsl:template match="*[@usehref]"> <xsl:copy> <xsl:variable name="prototype" as="element()?"> <xsl:evaluate xpath="@usehref" context-item="$prot-doc"/> </xsl:variable> <xsl:apply-templates select="." mode="merge-attributes"> <xsl:with-param name="prototype" select="$prototype"/> </xsl:apply-templates> <xsl:apply-templates select="." mode="merge-children"> <xsl:with-param name="prototype" select="$prototype"/> </xsl:apply-templates> </xsl:copy> </xsl:template>
<root> <draw name="Text1" usehref="/proto/draw[@name = 'TextStyle1']">
</draw> </root>
<proto> <draw name="TextStyle1" w="29.2864mm" h="5.2331mm">
</draw> </proto>
<root> <draw name="Text1" w="29.2864mm" h="5.2331mm"> <ui> <textEdit/> </ui> <value> <text/> </value> <border> <edge presence="hidden"/> </border> <font weight="bold" size="12pt" typeface="Myriad Pro"/> <margin topInset="0.5mm" bottomInset="0.5mm" leftInset="0.5mm" rightInset="0.5mm"/> </draw> </root>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] A use-case for xsl:merge?, John Dziurlaj john@x | Thread | Re: [xsl] A use-case for xsl:merge?, John Dziurlaj john@x |
Re: [xsl] A use-case for xsl:merge?, John Dziurlaj john@x | Date | Re: [xsl] A use-case for xsl:merge?, John Dziurlaj john@x |
Month |