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

Re: clever ways to dynamically copy/create element st

Subject: Re: clever ways to dynamically copy/create element structure as needed?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 2 Oct 2022 17:38:16 -0000
Re:  clever ways to dynamically copy/create element  st
Using parse-xml() to parse a literal string at run-time is going to be pretty
inefficient (although it might be optimiser if you're lucky). It might be a
bit more wordy, but a global variable

<xsl:variable name="empty-prolog" as="element(prolog)">
  <prolog/>
</xsl:variable>

is going to be a lot more efficient.

> On 2 Oct 2022, at 16:04, Chris Papademetrious
christopher.papademetrious@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Aaand posting again because I forgot the <xsl:copy> on the bmetadatab
template:
>
>
>   <xsl:mode name="add-data" on-no-match="shallow-copy"/>
>
>   <xsl:template match="topic" mode="add-data">
>     <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates select="title,titlealts,shortdesc,abstract"/>
>       <xsl:apply-templates select="(prolog,
parse-xml('&lt;prolog/&gt;'))[1]" mode="add-data"/>
>       <xsl:apply-templates select="body,related-links,topic"/>
>     </xsl:copy>
>   </xsl:template>
>
>   <xsl:template match="prolog" mode="add-data">
>     <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates
select="author,source,publisher,copyright,critdates,permissions"/>
>       <xsl:apply-templates
select="(metadata,parse-xml('&lt;metadata/&gt;'))[1]" mode="add-data"/>
>       <xsl:apply-templates
select="change-historylist,resourceid,data,sort-as,data-about,foreign,mathml,
svg-container,unknown"/>
>     </xsl:copy>
>   </xsl:template>
>
>   <xsl:template match="metadata" mode="add-data">
>     <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates
select="audience,category,keywords,prodinfo,othermeta"/>
>       <xsl:apply-templates select="data[not(@name = 'prefix')]"/>
>       <data name="prefix">my-prefix</data>
>       <xsl:apply-templates
select="sort-as,data-about,foreign,mathml,svg-container,unknown"/>
>     </xsl:copy>
>   </xsl:template>
>
>
> Sorry for all the list noise. I get too excited when my XSLT fiddle
worksb&
>
> Chris
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)

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.