473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unwanted empty xmlns string in the output.

CI
I have the following XML file:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<workbook xmlns="http://schemas.openxml formats.org/spreadsheetml/2006/
main" xmlns:r="http://schemas.openxml formats.org/officeDocument/2006/
relationships">
<fileVersion appName="xl" lastEdited="4" lowestEdited="4 "
rupBuild="4505"/>
<workbookPr defaultThemeVer sion="124226"/>
<bookViews>
<workbookView xWindow="120" yWindow="45" windowWidth="18 975"
windowHeight="1 1955" 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
<sheetelment(s) .
<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/
Transform"
xmlns:y="http://schemas.openxml formats.org/spreadsheetml/2006/
main"
xmlns:r="http://schemas.openxml formats.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="{@shee tId}" 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.openxml formats.org/spreadsheetml/2006/
main" xmlns:r="http://schemas.openxml formats.org/officeDocument/2006/
relationships">
<fileVersion appName="xl" lastEdited="4" lowestEdited="4 "
rupBuild="4505"/>
<workbookPr defaultThemeVer sion="124226"/>
<bookViews>
<workbookView xWindow="120" yWindow="45" windowWidth="18 975"
windowHeight="1 1955" 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

Mar 20 '07 #1
2 3785
CI wrote:
I created a stylesheet to get rid off the 'state' attribute of a
<sheetelment(s) .
<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/
Transform"
xmlns:y="http://schemas.openxml formats.org/spreadsheetml/2006/
main"
xmlns:r="http://schemas.openxml formats.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="{@shee tId}" 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/
Mar 20 '07 #2
CI
Thanks Martin. It worked.

Michael

Mar 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2235
by: Tjerk Wolterink | last post by:
I have an xsl file wich xsl:includes this file: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:page="http://www.wolterinkwebdesign.com/xml/page" xmlns:xc="http://www.wolterinkwebdesign.com/xml/xcontent"> <xsl:output method="xml" indent="yes"/>
18
2418
by: Tjerk Wolterink | last post by:
i have the following rule, <xsl:template match="br"> <br/> </xsl:template> This should convert all <br/> to <br/> but, my transformer transforms it all to
2
1555
by: Simon_Keep | last post by:
Hi, I have an Xslt extension object that returns a node-set to the xslt stylesheet which then uses an xsl:copy-to statement to write it to the output. The problem I am having is that the copied elements appear with an empty default namespace appearing on them (xmlns=""). The root element of the output XML does declare a default namespace (xmlns="urn:schemas-microsoft-com:office:spreadsheet").
0
2636
by: jennifer.perkins | last post by:
I've seen a couple posts by people having similar problems, but the suggested solutions I've tried so far haven't worked. I'm using a SOAP client in VB.Net (constructed by wsdl.exe) and the third party web service it's consuming is served by Axis. The request messages my client sends are processed fine by the server, and the SOAP response is making its way to my client - but when .Net finishes processing the message I end up with an...
4
3588
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C# code is, // Create an XSLT transform object XslTransform xslTransform = new XslTransform(); // Load the stylesheet
3
3698
by: Jeff Calico | last post by:
Hello everyone I am transforming an XML document to text, basically only outputting a small portion of it. When I run the following XSLT via Xalan's processor, I get a bunch of unwanted blank lines in the output. Here is a simplified XML and XSLT: (Note the problem does not happen when testing in XMLSpy) - - - - - - - - - - - - - - - - - - - - - - - -
0
1587
by: R. Ian Lee | last post by:
I've built an XSLT file that transforms data to SpreadsheetML format. The XSLT uses a <xsl:call-template/to build each worksheet. For some reason, when I transform the file, it is inserting xmlns="" attributes into my <Worksheetelements which causes the worksheet not to work with Excel. I'm using the System.Xml.Xsl.XslTransform class to perform the transform. Here's a snippet of the XSLT template that is called: <xsl:template...
0
1880
by: Fred | last post by:
I am trying to build a consumer to a webservice which use soapheader. I am using Visual Studio 2003. Please see the wsdl-file below. Why is it that the SOAPHEADER is empty when I use it int the header instead of as part of the input message? Is there a limitation of VS2003? Please any ideas are appreciated?! TIA Fred
3
2052
by: tschwartz | last post by:
I'm trying to write a stylesheet which removes nodes which are empty as a result of other template processing. For example, given the following xml, I'd like to: - remove all "b" elements - remove all "a" elements which, as a result of "b" element removal, now have no children so, starting with:
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.