Re: [xsl] Temporary tree elements and namespaces

Subject: Re: [xsl] Temporary tree elements and namespaces
From: "Sam Byland" <shbyland@xxxxxxxxxxx>
Date: Wed, 13 Feb 2008 16:57:14 -0500
Joco,

to specify a default namespace in XSLT 2, you use the "xpath-default-namespace" attribute. However, I don't fully understand your question:

After some wasted hours I've figured out that the
problem is the default namespace that Excel *requires* to be present.

Requires to be present in the output XML file? i.e you indicate you are "converting" an XML document to an Excel XML file; is your XSLT intending to do this conversion, or have you done a conversion manually and your XSLT below is intended to transform the converted (Excel) XML file?


The XSLT you provided does not output XML, but text; so I'm thinking that the "real" XML source you are having to use has some namespace issues making your code not work. If so, perhaps you could provide an input example where such namespaces are used?

=== XML FILE ===

<?xml version="1.0" encoding="ISO-8859-1"?>
<values>
  <value>0.123</value>
  <value>0.234</value>
</values>

In your "final version", are the values and value elements in some particular namespace that we don't see in this example?


I'm going to assume that is the case. For the following XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<values xmlns="some.Excel.default.namespace">
<value>0.123</value>
<value>0.234</value>
</values>

Your original XSLT file will work with just a few slight mods:

-- change your xsl:stylesheet line to something like this:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:foo="some.Excel.default.namespace">

-- then add foo: in a couple places:

<xsl:template match="/foo:values"> <-- here

<xsl:for-each select="foo:value"> <-- and here

Does that help?

...sam

Current Thread