Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   unwanted empty xmlns string in the output. (http://www.velocityreviews.com/forums/t485618-unwanted-empty-xmlns-string-in-the-output.html)

CI 03-20-2007 08:18 AM

unwanted empty xmlns string in the output.
 
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


Martin Honnen 03-20-2007 12:45 PM

Re: unwanted empty xmlns string in the output.
 
CI wrote:

> 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"/>

--

Martin Honnen
http://JavaScript.FAQTs.com/

CI 03-20-2007 03:34 PM

Re: unwanted empty xmlns string in the output.
 
Thanks Martin. It worked.

Michael



All times are GMT. The time now is 01:22 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.