Subject: [xsl] Re: Add element at the end of a variable group of elements From: "Charles O'Connor coconnor@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 3 Mar 2021 16:21:26 -0000 |
It should be added no matter what, so I believe the solutions presented here will work for my use case. The one wrinkle is that a <moon> element may already exist and should be replaced, but I believe I can handle that with my current (such as they are) skills. Thank you everyone for your answers. I really love this board and have gotten several solutions here, each of which has expanded my idea of what can be done with XSLT. I do hope to get good enough eventually to be able to contribute solutions as well. I just looked, and I'm on Step 10 (of ~70) of Ken's "Practical Transformation . . . " class on Udemy. Eventually . . . Liam, I will continue to annoy my IT/Engineering group to upgrade to a 3.0 processor. I suspect I'll get the same response. -----Original Message----- From: Michele R Combs mrrothen@xxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, March 3, 2021 9:28 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Re: Add element at the end of a variable group of elements *** External email: use caution *** Are there any conditions for adding <moon> -- like, add <moon> only if <earth>? Or do you want to add it 100% of the time, no matter what? Michele -----Original Message----- From: Charles O'Connor coconnor@xxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, March 2, 2021 7:01 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Add element at the end of a variable group of elements Hi all, Using XSLT 2.0, I'd like to add an element at the end of a group of elements that may vary whether they exist. This seems like a classic case that people have to deal with all the time, but I've searched without luck, and I'm on maybe lesson 4 of ??? of the online XSLT course I've been taking for the past decade. So, given the XML <root> <foo/> <bar/> <mercury/> <venus/> <earth earth-type="round"/> <earth earth-type="flat"/> <mars/> </root> I want to add <moon>Now with more craters!</moon> after the <foo>, <bar>, <mercury>, <venus> group of elements and before the <earth>, <mars> group of elements, BUT I only know for sure that <foo> and <mars> will exist in the input XML. All the others are optional. In the Oxygen XPath test window, "root/(foo|bar|mercury|venus)[last()]" got me where I wanted to be, but alas, parentheses are not allowed in the @match for the template. Thanks! Charles Charles O'Connor [he/him] l Business Analyst Aries Systems Corporation l www.ariessys.com 50 High Street, Suite 21 l North Andover, MA l 01845 l USA Direct: 802-585-5655 Main: 978-975-7570 l Help Desk: 978-291-1966 | Fax: 978-975-3811 This message is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you have received this message in error, do not open any attachment but please notify the sender (above) and delete this message from your system.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Add element at the end of, Michele R Combs mrro | Thread | Re: [xsl] Re: Add element at the en, Liam R. E. Quin liam |
[xsl] Re: Add element at the end of, Michele R Combs mrro | Date | Re: [xsl] Re: Add element at the en, Liam R. E. Quin liam |
Month |