[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: namespace problem

Subject: Re: namespace problem
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sun, 22 Apr 2001 16:43:49 +0100
xml namspace example
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.