Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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 July 31st, 2007, 11:10 PM
Suu Suu is offline
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Element Names - Dashes

I am starting to learn XML (just finished Chapter 2 of Beginning XML), so I apologize for the basic question.


Is it possible to start a name with a dash when naming elements?


I was doing the Exercise Questions and I noticed that starting a name with a dash is not valid; however, the text (Beginning XML) stated that "names can start with letters (including non-Latin characters) or the dash (-) character, but not numbers or other punctuation characters."

Just curious.

Thanks.

 
Old August 1st, 2007, 02:42 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

They can start with an underscore (_) but not a dash (-), see http://www.w3.org/TR/2006/REC-xml-20...sec-common-syn

--

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

An XML name can start with the Unicode character 5F (_) (commonly called Underscore, more correctly "Low line"). It cannot start with 2D (-) (correctly called "hyphen-minus"). There are various characters called Dash in Unicode including Figure Dash (2012), En Dash (2013), Em dash (2014), Swung dash (2053), and Wave dash (301C). As far as I can see all these are classified as punctuation, which means they cannot be used in names.

If Beginning XML refers to either of the hyphen-minus character or the low line character as a "dash" then I think you should send in a bug report.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 2nd, 2007, 08:49 AM
Suu Suu is offline
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! I found those answers helpful.

mhkay: Good idea. I just submitted in an Errata Form. I linked back to this thread, because of the helpful answers.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Dashes in the server name , cannot run sql cmd combo SQL Server 2000 6 June 20th, 2014 02:02 AM
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
Getting form element names in a loop crapanz Javascript 5 January 30th, 2006 12:45 AM
Duplicate Element Names carolynk XML 1 September 30th, 2004 09:22 AM
select wildcard element names groovepapa XSLT 4 September 1st, 2004 08:12 AM





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