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

Using XSLT as a namespace filter...

Subject: Using XSLT as a namespace filter...
From: Nathan Potter <ndp@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jan 2009 17:15:19 -0800
 Using XSLT as a namespace filter...
Greetings,

I have an application in which I want to pass only elements in a document that are members of a particular namespace. I want the elements, the attributes and text nodes, but no child elements or attributes from other namespaces.

Naively I though that I could just do something like this:


<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dap="http://xml.opendap.org/ns/DAP2"

>
<xsl:output method='xml' version='1.0' encoding='UTF-8' indent='yes'/>


   <xsl:template match="/dap:Dataset">
       <xsl:copy >
           <xsl:apply-templates />
       </xsl:copy>
   </xsl:template>

   <xsl:template match="dap:*">
       <xsl:copy >
           <xsl:copy-of select="dap:*" />
       </xsl:copy>
   </xsl:template>

   <xsl:template match="*">
       <xsl:apply-templates />
   </xsl:template>

   <xsl:template match="text()|@*">
           <xsl:copy-of select="." />
   </xsl:template>

</xsl:stylesheet>

But all of the text content of the elements from other namespaces leaks through.

I realize that this guy:

   <xsl:template match="text()|@*">
           <xsl:copy-of select="." />
   </xsl:template>

Is the culprit.

After many futile attempts at trying write an XPATH to match only text and attributes whose parent element is in the dap namespace I am here, looking for some advice.


Any ideas? I have this feeling that the solution to this should be really simple, and that my transform is already twice as long as it should be.


Nathan


============================================================ Nathan Potter Oregon State University, COAS ndp at coas.oregonstate.edu 104 Ocean. Admin. Bldg. 541 737 2293 voice Corvallis, OR 97331-5503 541 737 2064 fax

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.