Subject: Re: [xsl] clever ways to dynamically copy/create element structure as needed? From: "dvint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 1 Oct 2022 17:50:10 -0000 |
I don't have a specific sample and may not be clever. What I have done with this is to match on the prolog element and then process by the pieces I expect to be there. So checking for the various child elements of prolog. Test for their existence and if not there insert what you want. You need to also have a test that say at the topic/title element checks to see if there is a prolog element, so you can create one if it isn't there.Sent from my Verizon, Samsung Galaxy smartphone -------- Original message --------From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: 10/1/22 10:02 AM (GMT-08:00) To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] clever ways to dynamically copy/create element structure as needed? I forgot to mention one fun aspect. Sometimes the content models are order-specific: B topic = element topic { title, titlealts?, (shortdesc | abstract)?, prolog?, body?, related-links?, topic* } prolog = element prolog { author*, source?, publisher?, copyright*, critdates?, permissions?, (metadata | change-historylist)*, resourceid*, (data | sort-as | data-about | foreign | mathml | svg-container | unknown)* } metadata = element metadata { audience*, category*, keywords*, prodinfo*, othermeta*, (data | sort-as | data-about | foreign | mathml | svg-container | unknown)* } B so when new levels are created, they must be ordered correctly within whatever siblings might already exist. B Chris B B From: Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Saturday, October 1, 2022 12:28 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] clever ways to dynamically copy/create element structure as needed? B Hi everyone, B I want to use XSLT to add a piece of <data> metadata to a DITA topic. The DITA content model lets me place it at btopic/prolog/metadata/datab: B <topic id="topic"> B <title>My Topic</title> B <prolog> B B B <metadata> B B B B B <data name="prefix">my-prefix</data> B B B </metadata> B </prolog> B <body/> </topic> B Some, none, or all of the required bprolog/metadatab element structure might already exist: B <topic id="topic"> B <title>My Topic</title> B <body/> </topic> B <topic id="topic"> B <title>My Topic</title> B <prolog> B B B <author type="creator">chrispy</author> B B B <metadata> B B B B B <keywords> B B B B B B B <indexterm>some term</indexterm> B B B B B </keywords> B B B </metadata> B </prolog> B <body/> </topic> B My current XSLT code to do this is embarrassing. B Does anyone have a favorite way of adding an element at a particular hierarchy path, copying existing levels and creating missing levels as needed? B (This is just an example. I have other scenarios that require deeper element structures.) B Thanks! B ----- Chris Papademetrious Tech Writer, Implementation Group (610) 628-9718 home office (570) 460-6078 cell B XSL-List info and archive EasyUnsubscribe (by email) XSL-List info and archive EasyUnsubscribe (by email)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] clever ways to dynamicall, Chris Papademetrious | Thread | Re: [xsl] clever ways to dynamicall, Chris Papademetrious |
Re: [xsl] clever ways to dynamicall, Chris Papademetrious | Date | Re: [xsl] clever ways to dynamicall, Chris Papademetrious |
Month |