Subject: RE: [xsl] difficulties with exclude-result-prefixes and xsl:copy From: "Michael Kay" <mhkay@xxxxxxxxxxxx> Date: Thu, 9 Aug 2001 09:23:48 +0100 |
> Hi. I'm not sure how to do this the correct way. I have the > following XML: > > <xql:result> > <Aps:ProductStructure ino:id='4' > xmlns:Aps='http://www.foo.com/aps/' id='1'> > <Aps:AssemblyName>bar</Aps:AssemblyName> > <Aps:AlternateAssemblyName>testc</Aps:AlternateAssemblyName> > > And I want it returned to me exactly as it is without the > <xql:result> tag and > the > attribute ino:id after Aps:ProductStructure. First of all, the XML is well-formed but doesn't conform to the namespaces REC, because the prefixes "ino" and "xql" aren't declared. XSLT requires that the input conforms to the namespaces REC. There has been some discussion on the Tamino forum at http://www.tamino.com/ on how best to deal with this. One idea is to put a SAX filter in front of the XSLT processor, another is to wrap the XML inside another element that contains the namespace declarations, which you can do by treating the real document as an entity: <wrapper xmlns:ino="..." xmlns:xql="...">&realdoc;</wrapper> Declaring the namespace prefixes in the stylesheet doesn't solve the problem. Once you've constructed a well-formed document, you can achieve the copy you want by writing: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ino="http://namespaces.softwareag.com/tamino/response2" xmlns:xql="http://metalab.unc.edu/xql/"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:template match="xql:result"> <xsl:for-each select="*"> <xsl:variable name="ino-id" select-"generate-id(@ino:id)" <xsl:copy-of select="@*[generate-id()!=$ino-id]"/> <xsl:copy-of select="node()"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> You don't need exlcude-result-prefixes; that only affects namespaces written when copying a literal result element from the stylesheet, and this stylesheet doesn't contain any literal result elements. Feel free to raise questions related to Tamino on the Tamino developers' forum at http://www.tamino.com/ Mike Kay Software AG XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] difficulties with exclude, Trevor Nash | Thread | Re: [xsl] keys fast for lookups? at, David_Marston |
RE: [xsl] HTML section headings to , Beckers, Marc | Date | RE: [xsl] Capitalizing content of a, Joerg Pietschmann |
Month |