Subject: RE: [xsl] Namespace problem From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx> Date: Fri, 25 Sep 2009 02:56:41 +1200 |
Hi Martin Thank you for pointing out the distinction between an attribute and a namespace node, I wasn't aware of that. If I could use XSL 2.0 it would be easy, but unfortunately this stylesheet is run as part of FrameMaker's XML document load process, and it is thus limited to XSL 1.0 (Xalan, there is no alternative). Is there a version of your solution that would work in XSL 1? Cheers Trevor -----Original Message----- From: Martin Honnen [mailto:Martin.Honnen@xxxxxx] Sent: Friday, 25 September 2009 2:48 a.m. To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Namespace problem Trevor Nicholls wrote: > My root elements used to have local attributes, but now, thanks to the > miracle of XSD, they have two additional attributes, e.g. > <document > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" In the XSLT/XPath data model xmlns:xsi is not modelled as an attribute but rather as a namespace node. > xsi:noNamespaceSchemaLocation="../../xml_utils/hcdocs.xsd" > index="N" > mark="Y"> > > The stylesheet generating the output XML creates the DTD declaration with > <xsl:output > doctype-system="../../xml_utils/fmdocs.dtd" > method="xml" > encoding="UTF-8" /> > > and has some null templates suppressing attributes which are not needed in > the output documents, eg: > <xsl:template match="@indx|@mark|@formatted" /> > <xsl:template match="@rowspan[string(.)='1']" /> > <xsl:template match="@colspan[string(.)='1']" /> > <xsl:template match="@xml:space" /> > > Using the last of these as a "template" :-) I added two new lines to the > stylesheet doing this job for the schema version of the input: > <xsl:template match="@xsi:noNamespaceSchemaLocation" /> > <xsl:template match="@xmlns:xsi" /> > > These generate an error, because I haven't declared the namespaces, so I > added > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xmlns="" > > to the <xsl:stylesheet> declaration, thinking this would drop both > attributes. I wasn't sure what to put in the xmlns:xmlns one, as xmlns seems > to be a bit of a special case. However whatever I try isn't helping: the > xsi:noNamespaceSchemaLocattion attribute is being dropped, but the > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attribute is not. You will need to avoid copying namespace nodes you don't want to be copied. In XSLT 2.0 you can use e.g. <xsl:copy copy-namespaces="no"> respectively <xsl:copy-of select="foo" copy-namespaces="no"/> You will need to show us more of your stylesheet for suggestions on where exactly you need that. -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Namespace problem, Martin Honnen | Thread | Re: [xsl] Namespace problem, David Carlisle |
Re: [xsl] Namespace problem, andrew.j.welch | Date | Re: [xsl] Namespace problem, David Carlisle |
Month |