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

Re: Evaluating XML inside attributes (using XSLT 2.0 a

Subject: Re: Evaluating XML inside attributes (using XSLT 2.0 and Saxon)
From: Michael Ludwig <milu71@xxxxxx>
Date: Wed, 24 Mar 2010 23:46:56 +0100
Re:  Evaluating XML inside attributes (using XSLT 2.0 a
Jacobus Reyneke schrieb am 24.03.2010 um 20:39:27 (+0200):

> I can't get past the fact that sometimes I end up with attributes that
> will get part of their content from other parts of the XML document.

Fine.

> Can anyone please share some ideas around evaluating information for
> use inside xml attributes. I know it's ugly, horrible and terrible to
> escape XML an dump it inside an attribute

Should be avoided under all circumstances. No excuse :-)

> but I need to reference content by id from inside attributes from time
> to time.

Why don't you just use entities and entity references? Good old DTD does
the job for you:

$ cat five.xml
<!DOCTYPE root [
<!ENTITY johny "Johny">
]>
<root>
  <information lookup-id="5">
    &johny;             
  </information>
  <chapter title="The life of &johny;">
     Everyone knew that &johny; was a happy child  
  </chapter>
</root>

$ xmllint --noent five.xml
<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY johny "Johny">
]>
<root>
  <information lookup-id="5">
    Johny             
  </information>
  <chapter title="The life of Johny">
     Everyone knew that Johny was a happy child  
  </chapter>
</root>

That way, you won't need information/@lookup-id.

If you insist on using cryptic numbers, you could pre-generate the
entities and store them in a file called five.ent which you then
reference from the DOCTYPE.

-- 
Michael Ludwig

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-2011 All Rights Reserved.