Subject: Re: [xsl] Xpath Syntax Issue From: "Christopher R. Maden" <crism@xxxxxxxxx> Date: Sat, 23 Jun 2012 22:51:29 -0400 |
-----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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Xpath Syntax Issue, Nathan Tallman | Thread | Re: [xsl] Xpath Syntax Issue, Nathan Tallman |
Re: [xsl] Xpath Syntax Issue, Nathan Tallman | Date | Re: [xsl] Xpath Syntax Issue, Nathan Tallman |
Month |