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

Re: Xpath Syntax Issue

Subject: Re: Xpath Syntax Issue
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Sat, 23 Jun 2012 22:51:29 -0400
Re:  Xpath Syntax Issue
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/23/2012 10:38 PM, Nathan Tallman wrote:
> I still wasn't getting the results in my application, so I created
> pets.xml and sure enough the template worked. It only works with
> my original document if I remove attributes found in the root
> element.
>
> The original first 6 lines: <?xml version="1.0" encoding="UTF-8"?>
> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation=" http://www.sitemaps.org/schemas/sitemap/0.9
> http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
>
> I had to remove all attributes from <urlset> before the XSL would
> work. Do I need to reference the schema in my XSL?

Ahh... the good olb namespace FAQ.

Every element type name is a pair: namespace URI and local name.

What you thought was null-namespace plus bspeciesb is in fact
http://www.sitemaps.org/schemas/sitemap/0.9 plus bspeciesb (often
written as {http://www.sitemaps.org/schemas/sitemap/0.9}species).  An
XPath expression matching just bspeciesb matches {}species, which is a
*different name* than
{http://www.sitemaps.org/schemas/sitemap/0.9}species.

You need, in your XSLT, to declare something like
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" and then
use sitemap:species in your XPath.  (A shorter prefix might be in
order, but a prefix is required for XSLT 1.0 and recommended (IMO) for
clarity for XSLT 2.0.)

~Chris
- --
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
LIVE FREE: vote for Gary Johnson, Libertarian for President.
     <URL: http://garyjohnson2012.com/ >  <URL: http://lp.org/ >
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9  A210 4A51 DBAC 5C5C 3D5E


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJP5oCxAAoJEEpR26xcXD1eHSUH/0E0F49MPJJJ1j/1lB9Zw0zK
gNBxalYi/zVpHCgSYNzdXYrdvYWZFIDkQng4opPXBLA5nbWvaJ4qpObrMbB80cmN
unUmPhrb5IkuYx1adgCvNzxlRuabdG06jUUbO11kq8HPbyWH74tEsFP5+IPrTOpn
/xmZTkR5Z0kO93yl6osUbyeq42dF34HmyQKVwWQD0dXHVM8q5BUbVesnxmjdGoE9
7zZTJH+r3K0WhGbM0Iq91wZ4LF3qTT25gih+TBF3cMAzsBCGaxzzFlRoJj0qDVj2
q6DW/awQW+JU8VxRavaoQG1rk1No/k/GkStSv+UXCBdl3qwdwbVIXWdXaliZ0/o=
=YGiD
-----END PGP SIGNATURE-----

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.