Re: [xsl] Processing Stylesheet with multiple namespaces

Subject: Re: [xsl] Processing Stylesheet with multiple namespaces
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Sat, 22 Sep 2007 15:06:51 -0500
Michael

That's not the stylesheet I posted, as Abel points out you have extra apply-templates that are not needed.

Joe
----- Original Message ----- From: "Michael Daniloff" <mdanilof@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Saturday, September 22, 2007 2:48 PM
Subject: Re: [xsl] Processing Stylesheet with multiple namespaces



here it is Joe:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006";
xmlns:o="urn:schemas-microsoft-
com:office:office"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships";
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math";
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
xmlns:w10="urn:schemas-microsoft
-com:office:word"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main";
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml";
 exclude-result-prefixes="ve o r m v wp w10 w wne">

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

 <xsl:template match="w:object">
   <w:pict>
     <xsl:apply-templates/>
     <xsl:apply-templates select="w:OLEObject"/>
     <xsl:apply-templates select ="@o:ole"/>
   </w:pict>
 </xsl:template>

 <xsl:template match="w:OLEObject"/>
 <xsl:template match="@o:ole"/>

</xsl:stylesheet>

this version doesn't strip "o:ole" attribute from the
element v:shape

So, I came with this one that does the trick:

<xsl:stylesheet> - (M.D. skipped namespaces
declaration for clarity)

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

 <xsl:template match="w:object">
   <w:pict>
     <xsl:apply-templates/>
     <xsl:apply-templates select="v:shape" mode="k"/>
     <xsl:apply-templates select="w:OLEObject"/>
   </w:pict>
 </xsl:template>

 <xsl:template match="v:shape" mode="k">
   <v:shape>
     <xsl:attribute name="id">
       <xsl:value-of select="@id"/>
     </xsl:attribute>
     <xsl:attribute name="type">
       <xsl:value-of select="@type"/>
     </xsl:attribute>
     <xsl:attribute name="style">
       <xsl:value-of select="@style"/>
     </xsl:attribute>
     <xsl:apply-templates/>
   </v:shape>
 </xsl:template>

 <xsl:template match="v:shape"/>
 <xsl:template match="w:OLEObject"/>

</xsl:stylesheet>

This stylesheet strips everything that I don't need.

But, today I discovered that the source can also
contain o:OLEObject element instead of w:OLEObject

and this of course messes everything up.

I still think that I do something incorrectly with the
regard to the multiple namespaces. The one with the
"o" prefix just doesn't behave the way I expect it to.

Thanks,

Michael




____________________________________________________________________________________ Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz

Current Thread