Subject: Re: [xsl] Processing Stylesheet with multiple namespaces From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx> Date: Thu, 20 Sep 2007 15:17:12 -0500 |
<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 select="@*|node()"/> </w:pict> </xsl:template> <xsl:template match="w:OLEObject"/> <xsl:template match="@o:ole"/>
<w:pict> <xsl:apply-templates select="@*|node()"/> </w:pict> for w:pict depending on whether or not you want the attributes to remain.
Joe http://joe.fawcett.name
XSLT 1.0 Processor: MSXML
I have the following XML file (fragment):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:document 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"> <w:body>
<w:p w:rsidR="007D3364" w:rsidRDefault="007D3364" w:rsidP="007D3364"> <w:pPr> <w:pStyle w:val="NormalWeb"/> </w:pPr> <w:r> <w:t>sample</w:t> </w:r> <w:r w:rsidR="00200227"> <w:object w:dxaOrig="9689" w:dyaOrig="6866"> <v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype> <v:shape id="_x0000_i1025" type="#_x0000_t75" style="width:484.5pt;height:343.5pt" o:ole=""> <v:imagedata r:id="rId4" o:title=""/> </v:shape> <w:OLEObject Type="Embed" ProgID="Word.Document.12" ShapeID="_x0000_i1025" DrawAspect="Content" ObjectID="_1234025626" r:id="rId5"/> </w:object> </w:r> </w:p> </w:body> </w:document>
In my stylesheet I'm trying to replace <w:object> element with <w:pict> element.
Also, I have to get rid off <w:OLEObject> element and drop "o:ole" attribute from the <v:shape> element
Here is my stylesheet:
<?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="OLEObject"/> <xsl:apply-templates select ="@o:ole"/>
</w:pict> </xsl:template>
<xsl:template match="OLEObject"/> <xsl:template match="@o:ole"/>
</xsl:stylesheet>
The output is all right except that the <v:shape> element still has attribute "o:ole" present
Another thing is that I had to drop "w" prefix for the OLEObject element to get the desired output.
Thanks,
Michael
____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Processing Stylesheet with mu, Michael Daniloff | Thread | [xsl] Processing Stylesheet with mu, Michael Daniloff |
RE: [xsl] Processing Stylesheet wit, cknell | Date | Re: [xsl] variable outside a for-ea, Abel Braaksma |
Month |