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

Re: Transform selected attribute to element when eleme

Subject: Re: Transform selected attribute to element when element already has a value | XSLT 2.0
From: "Sam Spade anonymousjuly1@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 22 May 2021 00:01:07 -0000
Re:  Transform selected attribute to element when eleme
Hi, Martin:

B B B B B B B B B B B  The purposesof flattening the XML are:

1.B B B B After the $keepAttr is flattened to element (therewill not be any
attribute ), I can further transform the flattened XML to JSON.That is the
purpose of this post:

https://stackoverflow.com/questions/67145900/xquery-constructs-string-object-
with-sequential-ancestor-node-names
The original <businessCenters> will be transformed to JSON array.
B B B B B B B B B B B B B B B B B  <calculationPeriodDatesAdjustments>
B B B B B B B B B B B B B B B B B B B 
<businessDayConvention>PRECEDING</businessDayConvention>
B B B B B B B B B B B B B B B B B B B  <businessCenters id="businessCenters">
B B B B B B B B B B B B B B B B B B B B B 
<businessCenter>USNY</businessCenter>
B B B B B B B B B B B B B B B B B B B B B 
<businessCenter>GBLO</businessCenter>
B B B B B B B B B B B B B B B B B B B  </businessCenters>
B B B B B B B B B B B B B B B B B  </calculationPeriodDatesAdjustments>

B 
It is legitimate to transform id as child element of <businessCenters>. But
data transformation is not just for convenience,if I transform that id out of
<businessCenters> as a sibling of <businessDayConvention>. B The context of
idB  is completed lost. In asearch engine, index broot/businessCenters/idb
vs broot/idb returns differentvalue.B 


    On Friday, May 21, 2021, 10:35:53 a.m. MST, Martin Honnen
martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

 On 21.05.2021 16:30, Sam Spade anonymousjuly1@xxxxxxxx wrote:
> |The transformation logic:
> |||
>
> |
> 1) transform namespace
>
> 2) transform root element
>
> 3) transform the selected attribute(s) to element (the attribute name is
> parameterised not hard-coded)
>
> 4) the transformed element shouldn't contain both other element
> (transformed from the attribute) and its original data
> |
>
> |
> The desired result:
>
> |<requestProduct xmlns="http://fc.fasset/product"> <trade> <cal>
> <c>PRECEDING</c> <bcs> <id>businessCenters</id> <bc>USNY</bc>
> <bc>GBLO</bc> </bcs> </cal> <amount> *<currency>USD</currency>
> <id>settlementCurrency</id>*
> <referenceAmount>StandardISDA</referenceAmount>
> <cashSettlement>true</cashSettlement> </amount> </trade> </requestProduct>|
>
> What is wrong with my module? How can I transform the input to the
> desired result? |

What is the criteria to transform an attribute to a child element of its
parent as is done for the "id" of the "bcs" element and what is the
criteria for the other choice, to not include the new element as a child
but to make it a sibling of the (previous) parent element?

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.