[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

A use-case for xsl:merge?

Subject: A use-case for xsl:merge?
From: "John Dziurlaj john@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Feb 2019 19:08:37 -0000
 A use-case for xsl:merge?
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.