Subject: Re: namespace problem
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sun, 22 Apr 2001 16:43:49 +0100
|
Hi,
> I got an xml file with namspace
>
> <?xml version="1.0" encoding="gb2312"?>
> <?xml-stylesheet type="text/xsl" href="sortsample.xsl"?>
> <a:bookinfo xmlns:a="http://www.example.com/catalog/">
[snip]
>
> then how should i write proper XSLT file to retrieve information
> from this document?
You need to define the same namespace in the XSLT stylesheet as well,
and give it a prefix. It doesn't matter what prefix you use, but you
may find it easiest to use the same one as you use in the XML
document, just to avoid confusion. So something like:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://www.example.com/catalog/">
...
</xsl:stylesheet>
Then you can do things like select the books in the catalog with:
/a:bookinfo/a:books/a:book
> if i use defaul namespace as
> xmlns="http://www.example.com/catalog/>", how should i do same thing
> as above?
In the same way as above. The important thing is that while you can
use the default namespace in the XML document, you *must* declare a
prefix for it in the XSLT stylesheet.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
- namespace problem
- ºÎº¼¾ü - Sun, 22 Apr 2001 00:41:09 -0400 (EDT)
- Jeni Tennison - Sun, 22 Apr 2001 11:44:36 -0400 (EDT) <=
|
|