|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: namespace problem
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








