Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2007, 06:43 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Not using Namespace prefixes

Hi all,

Sorry if this is a stupid question, but I was wondering that instead of having my xsl declaration with my namespace in it:
Code:
<xsl:stylesheet version="2.0" xmlns:cc="urn:callcredit.plc.uk/api5" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
...and then referencing it like this

Code:
<xsl:value-of select="/cc:Application/cc:Applicant/cc:Name/cc:Forename" />
is it possible to somehow do away with the need to put cc infront of every xpath query? (There is only one namespace in the entire document).

Many thanks,

Simon
 
Old August 16th, 2007, 07:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Since you are using XSLT 2.0 you can set

xpath-default-namespace="urn:callcredit.plc.uk/api5"

Incidentally, there is no need to declare or use the fn: prefix for functions in XSLT. You can use the names of system functions unprefixed, for example count(), just as in XSLT 1.0.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 20th, 2007, 05:36 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot Michael; was a great help :D

 
Old August 20th, 2007, 10:30 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry about the double post business... we have realised that we are going to have to do this stylesheet in XSLT 1.0. Is there an equivalent way of omitting the namespace from each xpath call?

Many thanks,

Simon

 
Old August 20th, 2007, 10:49 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

No. I suppose you could pre-process the XML first but that would need the prefixes declaring for that transform...

--

Joe (Microsoft MVP - XML)
 
Old August 20th, 2007, 10:52 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

No, there is no equivalent mechanism in XSLT 1.0.

Anyone who still has to code in 1.0 has my deepest symphathy.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 19th, 2012, 04:23 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rushman
Default A good laugh from the future!

Quote:
Originally Posted by mhkay View Post
Anyone who still has to code in 1.0 has my deepest symphathy.

Michael Kay
Oh Michael! If you only knew at the time of your posting...

Here I am, June of 2012, still coding with XSLT 1.0 ...

And no, it isn't MY choice ;o)
__________________
Dijkstra's law on Programming and Inertia:

If you don't know what your program is supposed to do, don't try to write it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
exclude-result-prefixes="#all" and xsi:type maxtoroq XSLT 2 November 7th, 2008 08:46 PM
XML problems - prefixes and asp.net supergirl_gem XSLT 7 July 3rd, 2007 01:56 AM
extension-element-prefixes alapati.sasi XSLT 2 April 30th, 2007 03:35 AM
XPATH: Retrieve Value without namespace prefixes ramesh.kumarm XSLT 4 September 14th, 2006 03:50 AM
maximum number of prefixes? gumgak ASP.NET 1.0 and 1.1 Basics 5 February 13th, 2006 09:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.