Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] XML with Default Namespace

From: "Andrew Welch" <andrew.j.welch@--------->
To:
Date: 8/1/2007 9:34:00 AM
On 8/1/07, Karl Stubsjoen <kstubs@xxxxxxxxx> wrote:
> I'm stuck, I'm trying to write XPATH against an Excel worksheet
> converted to XML, I'm actually trying to transform it into clean and
> nice xml, but darnit, the default namespace is throwing me off!
>
> I'm getting an error from XpathMania which says
> "Document has a default namespace"
>
> When I add the default namespace, then my xpath queries no longer work.
>
> So the XML looks like this:
>
> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
>  xmlns:o="urn:schemas-microsoft-com:office:office"
>  xmlns:x="urn:schemas-microsoft-com:office:excel"
>  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
>  xmlns:html="http://www.w3.org/TR/REC-html40">
>  <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
>   <Author>kstubsj</Author>


I'm not too sure what your question is Karl... but if it's "how do I
match elements in a default namespace" then:

In XSLT 2.0 - set the xpath-default-namespace to the namespace and
you're done, eg:

<xsl:stylesheet
  xpath-default-namespace="urn:schemas-microsoft-com:office:spreadsheet"

Or, in XSLT 1.0 (or just because its more explicit) assign the
namespace to a prefix in your stylesheet and update all of your paths:

<xsl:stylesheet
  xxmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"

select="//ss:foo/ss:bar"

cheers
andrew

-- 
http://andrewjwelch.com


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent