xsl-list
[Top] [All Lists]

Re: [xsl] flattening an xml hierarchy

2009-01-08 16:04:04
 <xsl:template match="Dontwant1 | dontwant2">

I get the unwanted elements as well.

why do you think?

you are searching for a node that is not there in your source.
GetNextDocumentResponse in your source belongs to a namespace
"http://www.BargeEx.com/BargeExService"; so you must first define a
namespace say "bargeExns"
and use the namespace prefix to pull the nodes you want. The following
should work for you. You have to refer to a node by its namespace, if
the node in the source has a namespace associated with it.



<xsl:stylesheet version="1.0" xmlns:bargeExNs =
"http://www.BargeEx.com/BargeExService";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:template match="node()|@*">
                <xsl:copy>
                        <xsl:apply-templates select="node()|@*"/>
                </xsl:copy>
        </xsl:template>
        <xsl:template match = "bargeExNs:EquipmentStatusDocument">
                <xsl:apply-templates select="node()|@*"/>
        </xsl:template>
        </xsl:stylesheet>
 HTH


2009/1/8 Tim <timlhunt(_at_)mindspring(_dot_)com>:
I thought a simple example would be able for me to extrapolate to one with
namespaces. When I run your transform with
  <xsl:template match="GetNextDocumentResponse | GetNextDocumentResult |
Document">
replacing
 <xsl:template match="Dontwant1 | dontwant2">

I get the unwanted elements as well.


I am looking to remove the top three elements of the below [accurate]
example:
<GetNextDocumentResponse xmlns="http://www.BargeEx.com/BargeExService";>
  <GetNextDocumentResult>Success</GetNextDocumentResult>
  <Document>
      <EquipmentStatusDocument
xmlns="urn:x12:schemas:BEX200808:StatusDocuments">
          <DocumentHeader/>
          <DocumentDetail>
           ....
          </DocumentDetail>
          </DocumentHeader/>
      </EquipmentStatusDocument>

Thanks, again.
Tim


Martin Honnen wrote:

Tim wrote:

I'd like to remove some elements from an xml hierachy using xslt:

Original xml example:
<Dontwant1>
  <dontwant2>foo</dontwant2>
  <x3>
      <x4>stuff</x4>
      <y5>more stuff</y5>
  </x3>
</Dontwant1>

Like to have transform output:
<x3>
 <x4>stuff</x4>
  <y5>more stuff</y5>
</x3>

 <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
 </xsl:template>

 <xsl:template match="Dontwant1 | dontwant2">
    <xsl:apply-templates select="*"/>
 </xsl:template>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 
Vasu Chakkera
Numerical Algorithms Group Ltd.
Oxford
www.vasucv.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--