Subject: Re: [xsl] Trying to remove default namespace declaration in output From: "dvint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 5 Mar 2019 16:32:27 -0000 |
Thanks, I was just recognizing the xsl:copy was generating the name space info. In DITA the name space I believe us more for the version attribute that is defaulted in the DTD as well. The content doesn't leverage the namespace.Sent from my T-Mobile 4G LTE Device -------- Original message -------- From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: 3/5/19 8:06 AM (GMT-08:00) To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Trying to remove default namespace declaration in output 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:templateB name="processAtrbiutes">B B B <xsl:apply-templatesB select="./@*"/></xsl:template><xsl:template match="@class | @domains | @DITAArchVersion | @ux-source-priority"/><xsl:template match="@*"><xsl:copy/></xsl:template>Michael KaySaxonicaB 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 definitionB xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"This is the primary template that is doing the transformationB B B <xsl:template match="node()" priority="-10">B B B B <xsl:copy>B B B B B B <xsl:call-template name="processAtrbiutes"/>B B B B B B <xsl:apply-templates select="node()"/>B B B B </xsl:copy>B B </xsl:template>And this is the template that I have handling the attributes <xsl:template name="processAtrbiutes">B B <xsl:for-each select="./@*">B B B B <xsl:choose>B B B B B B <xsl:when test="name(.) = 'class'">B B B B B B B B <!-- Remove -->B B B B B B </xsl:when>B B B B B B <xsl:when test="name(.) = 'domains'">B B B B B B B B <!-- Remove -->B B B B B B </xsl:when>B B B B B B <xsl:when test="local-name(.) = 'DITAArchVersion'">B B B B B B B B <!-- Remove -->B B B B B B </xsl:when>B B B B B B <xsl:when test="local-name(.) = 'ditaarch'">B B B B B B B B <!-- Remove -->B B B B B B </xsl:when>B B B B B B <xsl:when test="local-name(.) = 'ux-source-priority'">B B B B B B B B <!-- Remove -->B B B B B B </xsl:when>B B B B B B <xsl:otherwise>B B B B B B B B <xsl:attribute name="{local-name(.)}" select="."/>B B B B B B </xsl:otherwise>B B B B </xsl:choose>B B </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 EasyUnsubscribe (by email)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Trying to remove default , Eliot Kimber ekimber | Thread | [xsl] [ANN] Call For Participation:, Tommie Usdin btusdin |
Re: [xsl] Trying to remove default , Michael Kay mike@xxx | Date | [xsl] [ANN] Call For Participation:, Tommie Usdin btusdin |
Month |