Subject: [xsl] A use-case for xsl:merge? From: "John Dziurlaj john@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 15 Feb 2019 19:08:37 -0000 |
Hello, This is my first post! Ibve been working in XML for about 12 years, but havenbt gotten into XSLT processing seriously until recently. I am tasked to write an XSLT3 script to merge some XML. For purposes of my contrived example, each draw element can reference a prototype (via the @usehref element, representing a FQ XPath), which provides default values that can be overridden by its referrer: DRAW USING A PROTOTYPE (referrer): <draw name="Text1" usehref="/proto/draw[name = *'TextStyle1'*]"> <ui> <textEdit/> </ui> <value> <text>This is some text</text> </value> <border/> <font weight="bold"/> </draw> THE PROTOTYPE ITSELF: <draw name="*TextStyle1*" w="29.2864mm" h="5.2331mm"> <ui> <textEdit/> </ui> <border> <edge presence="hidden"/> </border> <font size="12pt" typeface="Myriad Pro"/> <margin topInset="0.5mm" bottomInset="0.5mm" leftInset="0.5mm" rightInset="0.5mm"/> </draw> The expected result is a combination of all the elements under draw (order of occurrence at any level does not matter). If an element or attribute is defined by both the prototype and its referrer, the referring particle should take precedence. EXPECTED COMBINED RESULT: <draw name="Text1" vAlign="top" h="5.2331mm" w="29.2864mm"> <ui> <textEdit/> </ui> <value> <text>This is some text</text> </value> <border> <edge presence="hidden"/> </border> <font weight="bold" typeface="Myriad Pro" size="12pt"/> <margin bottomInset="0.5mm" leftInset="0.5mm" rightInset="0.5mm" topInset="0.5mm"/> </draw> I tried to use the xsl:merge function in XSLT3 but I find the syntax a little confusing. Ibm using SAXON-PE 9.8. John DziurEaj Elections Consultant Hilton Roscoe LLC Cell 330-714-8935 Work/Fax 234-706-6434 PGP Fingerprint: 8466 BB28 6A92 EE06 F71D 1519 FB42 2861 6DC0 E92C
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT for CSV to XML Conve, Martin Honnen martin | Thread | Re: [xsl] A use-case for xsl:merge?, Martin Honnen martin |
[xsl] XSLT for CSV to XML Conversio, Rahul Singh rahulsin | Date | Re: [xsl] A use-case for xsl:merge?, Martin Honnen martin |
Month |