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

Re: Rebuild an element without copying defaulted attr

Subject: Re: Rebuild an element without copying defaulted attributes?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Aug 2014 16:45:36 -0000
Re:  Rebuild an element without copying defaulted  attr
There's no processor-independent way of preventing default attributes being
expanded. But some XML parsers have an option to disable this.

Saxon has an option -expand:off on the command line, or
FeatureKeys.EXPAND_ATTRIBUTE_DEFAULTS in the Java API, which switches this
behaviour on if you're using a parser that supports it.

Michael Kay
Saxonica
mike@xxxxxxxxxxxx
+44 (0) 118 946 5893




On 12 Aug 2014, at 17:22, dvint@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> I have a situation where I need to process 4,000 DITA topics to update
> them. I'm making updates which will then be included in the production
> data going forward. I need to modify certain elements and pass others
> through unchanged.
>
> My problem is the unchanged.
>
> So there is an element <pre> that has a defaulted @xml:space set to
> preserve. When I rebuild this element and recreate all the existing
> attributes my output now has a hard coded attribute setting.
>
> So
>
>    <pre ixia_locid="7">there's also the Duplicate Supplier Taxpayer ID
> Number Report</pre>
>
> became
>
> <pre ixia_locid="7" xml:space="preserve">there's also the Duplicate
> Supplier Taxpayer ID Number Report</pre>
>
> It seems like the only way I can avoid getting the defaulted attributes
> copied is to remove the reference to the DTD in all the topics. Is there
> any other way to accomplish this?
>
> Currently I'm using this template:
>
> <xsl:template match="*">
> <xsl:element name="{name(.)}">
> <xsl:for-each select="@*">
>    <xsl:attribute name="{name(current())}" ><xsl:value-of
> select="."/></xsl:attribute>
> </xsl:for-each>
> <xsl:apply-templates/>
> </xsl:element>
> </xsl:template>

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.