unwanted empty xmlns string in the output.

Discussion in 'XML' started by CI, Mar 20, 2007.

  1. CI

    CI Guest

    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
     
    CI, Mar 20, 2007
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Mar 20, 2007
    #2
    1. Advertising

  3. CI

    CI Guest

    Thanks Martin. It worked.

    Michael
     
    CI, Mar 20, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,365
  2. Lukas
    Replies:
    3
    Views:
    816
    spiff
    Nov 10, 2005
  3. Jeff Calico
    Replies:
    3
    Views:
    1,350
    Joe Kesselman
    Feb 9, 2006
  4. Replies:
    3
    Views:
    262
  5. afshar
    Replies:
    3
    Views:
    24,323
    aljar
    May 19, 2010
Loading...

Share This Page