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

RE: difficulties with exclude-result-prefixes and xsl:

Subject: RE: difficulties with exclude-result-prefixes and xsl:copy
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Thu, 9 Aug 2001 09:23:48 +0100
ino id tamino
> 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

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.