Home > SOA Tips > XML Developer > Euro symbols and XML Schema
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

XML DEVELOPER

Euro symbols and XML Schema


Ed Tittel and Lucinda Dykes
02.12.2003
Rating: -3.67- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



XML Developer Tip
(Receive this column in your inbox,
click Edit your Profile to subscribe.)

Euro symbols and XML Schema
Ed Tittel and Lucinda Dykes

XML developers whose work includes European markets may need to include the Euro symbol (€) in their documents. Although including entities is easily accomplished when using a DTD (see "Euro Symbols and XML documents"). We've reworked that earlier tip here, in response to reader requests to use XML Schema instead of DTD; alas, it's much more challenging when using XML Schema.

Character entities are XML general entities that provide a name for a single Unicode character. Character entities can be referenced using a numeric character reference, for example, the decimal € or the hexadecimal € for the Euro symbol. The Euro symbol can be used as data in an XML element or attribute when used in this numeric character reference form. (Numeric character references can't be used in CDATA sections or in XML names, however.) Character entities can also be referenced using a named character entity, for example, € for the Euro symbol.

Developers accustomed to declaring entities in DTDs soon discover that XML Schema offer no comparable mechanism for use of entities. Entities continue to be such a controversial area of XML Schema that the W3C XML Core Working Group issued a consensus statement on the topic of character entities in November 2002. In short, the consensus statement says that DTDs are an existing mechanism for declaring entities, and therefore there is no need to create a new way to include entities in XML documents.

So how do you include entities when using XML Schema? Let's start with the W3C XML Schema Recommendation, and then look at a new approach.

The W3C Schema Recommendation offers two different methods for using entities with XML Schema. The first method is to use


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
XML and XML schema
SOA pattern of the week (#7): policy centralization
Try XML-based Extensible Business Reporting Language (XBRL) for accounting reports
What's new at the W3C
Ganymede: Modeling tools target SOA, UML
Data services mashups emerge for SOA
Making sense of data services mashups
XML turns 10
SOA helps save 100-year-old business
Oracle maps heterogeneous data services strategy for SOA
Handling XML with Ajax

XML
National Weather Service policy supports XML
XML and democracy at work: The Election Markup Language (EML)
For interesting interface access, check out Xamlon
Royalty-free, revolutionary UBL
Altova strikes again with MapForce 2005
Beating the RSS crunch with aggregation/bloglines
Voice, speech, SIP, and XML: ECMA-269
Microsoft Baseline Security Analyzer and XML
An open source, native XML database: dbXML 2.0
Second-generation XML security preview: SAML

XML Developer
Use the soapUI software tool to tame WSDL
WSDL 2.0, new messaging for Web services
Using RELAX NG For data integration
Efficient XML Interchange tackles data verbosity
XML to DDL imports, synchronizes database schemata
The basics of MathML 3.0
Migrating to XSLT 2.0
What's up with XML 2.0?
Say hello to XPath 2.0
Podcasting software covers many bases

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
class diagram  (SearchSOA.com)
Fast Infoset (FI)  (SearchSOA.com)
GeoRSS  (SearchSOA.com)
Keyhole Markup Language  (SearchSOA.com)
RELAX NG  (SearchSOA.com)
state diagram  (SearchSOA.com)
Universal Business Language  (SearchSOA.com)
Vector Markup Language  (SearchSOA.com)
XML infoset  (SearchSOA.com)
XML pipeline  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


an internal DTD subset to declare an entity, for example, to use the Euro symbol in an XML instance document such as the following:

This instance document is constrained by a schema. When this document is processed, the entity reference will be replaced by the entity content—this occurs before schema validation occurs, so the schema processor will use 40 € as the value of the price element. However, what the W3C Recommendation fails to mention is that if an internal DTD subset is used, you'll need to include ELEMENT declarations for every element in the document, as well as ATTLIST declarations, to avoid validation errors.

The second method is to declare the character entity as an element within a schema document, and make the element's content fixed, for example:

This element can then be used in an XML instance document, such as the following:

There is yet another approach. This method uses an XSLT library called xmlchar that provides named elements for all of the character entities of HTML 4, including the Euro character. This method is similar to the second W3C method mentioned earlier, but it's designed to be used with XSLT stylesheets. This approach works only for element content, not attribute values. The xmlchar stylesheet can be imported into an existing xslt stylesheet using <xsl:import>, as follows:

Any xmlchar elements added to an XML document will be converted to the appropriate character entity in the output.

Until the time that a more straightforward method exists for using character entities with XML schemas (and yes, despite the consensus statement, we're still hoping!), you can use character entities and XML schemas by using one of these three techniques.

For more information on xmlchar, see the article "Named Character Elements for XML" by Anthony Coates and Zarella Rendon. For more details on using the Euro character in XML documents, see Rick Jelliffe's "Euro-XML".


About the Author

[IMAGE]Ed Tittel is a 20-plus year veteran of the computing industry, who's worked as a programmer, manager, systems engineer, instructor, writer, trainer, and consultant. He's also the series editor of Que Certification's Exam Cram 2 and Training Guide series, and writes and teaches regularly on Web markup languages and related topics.

Lucinda Dykes is the principal at Zero G Web Design in Santa Fe, New Mexico, and has been developing Websites and writing code since 1994. She teaches Web-related topics at Santa Fe Community college and has contributed to numerous books on XML.


For More Information:


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts