unwanted empty xmlns string in the output.

C

CI

I have the following XML file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/
main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships">
<fileVersion appName="xl" lastEdited="4" lowestEdited="4"
rupBuild="4505"/>
<workbookPr defaultThemeVersion="124226"/>
<bookViews>
<workbookView xWindow="120" yWindow="45" windowWidth="18975"
windowHeight="11955" activeTab="2"/>
</bookViews>
<sheets>
<sheet name="chicago" sheetId="1" r:id="rId1"/>
<sheet name="boston" sheetId="2" state="hidden" r:id="rId2"/>
<sheet name="austin" sheetId="3" r:id="rId3"/>
</sheets>
<calcPr calcId="124519"/>
</workbook>


I created a stylesheet to get rid off the 'state' attribute of a
<sheet> elment(s).


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
xmlns:y="http://schemas.openxmlformats.org/spreadsheetml/2006/
main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships"
exclude-result-prefixes="y">

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

<xsl:template match="y:sheet">
<sheet name="{@name}" sheetId="{@sheetId}" r:id="{@r:id}">
<xsl:apply-templates/>
</sheet>
</xsl:template>

</xsl:stylesheet>


And here is the result I get:

<?xml version="1.0"?>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/
main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships">
<fileVersion appName="xl" lastEdited="4" lowestEdited="4"
rupBuild="4505"/>
<workbookPr defaultThemeVersion="124226"/>
<bookViews>
<workbookView xWindow="120" yWindow="45" windowWidth="18975"
windowHeight="11955" activeTab="2"/>
</bookViews>
<sheets>
<sheet name="chicago" sheetId="1" r:id="rId1" xmlns=""/>
<sheet name="boston" sheetId="2" r:id="rId2" xmlns=""/>
<sheet name="austin" sheetId="3" r:id="rId3" xmlns=""/>
</sheets>
<calcPr calcId="124519"/>
</workbook>

The tool used is MSXML.


I would greatly appreciate if anyone can suggest how to avoid having
xmlns="" in my output tree.

Regards,

Michael
 
M

Martin Honnen

CI said:
I created a stylesheet to get rid off the 'state' attribute of a
<sheet> elment(s).


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
xmlns:y="http://schemas.openxmlformats.org/spreadsheetml/2006/
main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/
relationships"
exclude-result-prefixes="y">

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

<xsl:template match="y:sheet">
<sheet name="{@name}" sheetId="{@sheetId}" r:id="{@r:id}">
<xsl:apply-templates/>
</sheet>
</xsl:template>

It should suffice to use
<xsl:template match="@state"/>
in addition to your first template. That would delete all state
attributes on all elements. If you want to have it for the sheet
elements only then use e.g.
<xsl:template match="y:sheet/@state"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top