This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]