Subject: Re: [xsl] Trying to remove default namespace declaration in output From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 5 Mar 2019 17:38:02 -0000 |
The DITA ditaarch:DITAArchVersion attribute only occurs on <map> and <topic> elements and the namespace is only used for that attribute--no other elements or attributes defined by the DITA specification are in a namespace. The namespace declaration attribute is defaulted in normal DITA grammars so if you are generating documents where defaulted attributes are omitted then it's always safe to both suppress the attribute and omit the namespace declaration. Thus you can use copy-namespaces="no on <xsl:copy>. I thought I had general DITA identity transform XSLT code in a public project but I can't find it now. Cheers, E. -- Eliot Kimber http://contrext.com o;?On 3/5/19, 10:06 AM, "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: xmlns:ditaarch is a namespace, not an attribute (namespaces are not attributes in the XDM data model). The way to drop a namespace depends on whether the namespace is actually used or not. Sometimes when people say they want to drop a namespace declaration, what they actually want to do is to move the elements into a different namespace. From your question, it's not clear whether that is the case here. To drop an unused namespace, in XSLT 2.0 you can do <xsl:copy copy-namespaces="no">, while in 1.0 you need to use <xsl:element name="{local-name()}">. To move an element into a different namespace, you have to use <xsl:element> rather than <xsl:copy>. You template rule for attributes could be replaced with the much simpler: <xsl:template name="processAtrbiutes"> <xsl:apply-templates select="./@*"/> </xsl:template> <xsl:template match="@class | @domains | @DITAArchVersion | @ux-source-priority"/> <xsl:template match="@*"><xsl:copy/></xsl:template> Michael Kay Saxonica On 5 Mar 2019, at 15:46, dvint@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: I'm using XSLT to process DITA topics. This is a conversion/cleanup effort to try and normalize our content before loading into a new CMS. So basically doing an identity transformation with some random modifications. In the DTD is the definition xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" This is the primary template that is doing the transformation <xsl:template match="node()" priority="-10"> <xsl:copy> <xsl:call-template name="processAtrbiutes"/> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> And this is the template that I have handling the attributes <xsl:template name="processAtrbiutes"> <xsl:for-each select="./@*"> <xsl:choose> <xsl:when test="name(.) = 'class'"> <!-- Remove --> </xsl:when> <xsl:when test="name(.) = 'domains'"> <!-- Remove --> </xsl:when> <xsl:when test="local-name(.) = 'DITAArchVersion'"> <!-- Remove --> </xsl:when> <xsl:when test="local-name(.) = 'ditaarch'"> <!-- Remove --> </xsl:when> <xsl:when test="local-name(.) = 'ux-source-priority'"> <!-- Remove --> </xsl:when> <xsl:otherwise> <xsl:attribute name="{local-name(.)}" select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> Basically I want to copy the attributes in the XML file that have been applied and remove anything that has a default in the DTD. I have the ditaarch test here that is doing no good, but the other tests do what they are supposed to. For the namespace I tried declaring this namespace on the <xsl:stylesheet> element and then exclude it but that didn't work either. Any suggestions? ..dan XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by email <>) XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/1278982> (by email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Trying to remove default , Michael Kay mike@xxx | Thread | Re: [xsl] Trying to remove default , dvint dvint@xxxxxxxx |
[xsl] [ANN] Call For Participation:, Tommie Usdin btusdin | Date | [xsl] XSLT 2 and XSLT 3: Best Way T, Eliot Kimber ekimber |
Month |