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

Re: Displaying one section of XML file at a time -- p

Subject: Re: Displaying one section of XML file at a time -- posting again
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Mon, 27 Mar 2006 16:49:32 -0600
xml file javascript
> Will appreciate if you could take a look at my
> XML/XSLT/JS code and let me know what is missing or
> where I am going wrong.

Like I've mentioned before, it's useful to be able to look at all
stages of the transformation.



> My XML file:
> <cd id="1">

> <cd id="2">

Word of warning.  In the XML world id attributes tend to be special
(depending on the tools for specifying, but assuming a classical
approach) and shouldn't start with numbers.  The id would typically be
something like c1, perhaps.  I don't think this will cause an error
necessarily at any point, but it might in some tools.


> <h2>
> <a href='javascript:void(0);' onClick="toggle('$id')">
                                                                   ^^^^

I think you're trying to do attribute value templates.  See
http://www.w3.org/TR/xslt#attribute-value-templates.  Remember XSLT
doesn't know anything about the output format.  So if you do this it
will literally put out toggle($id) (view the generated source).

> <div style="display:none" id="$id">
                                              ^^^^^
And here you assign all the elements the literal id value $id.  Hence
there's a conflict in ids, and browsers will behave unpredictably.
Most will probably just grab the first element with that id.

You really do need to make sure you have some way of viewing the
generated html page.  Either using view generated source via a plugin
or browser setting or generating using a stand-alone processor.  This
would have been much easier to notice had you done this.  Both
elements have the id $id, and both javascript calls toggle the
function $id.

You might want to look more into event listeners with Javascript for
how you're setting it up once you are more comfortable with the
language, but I won't get into any detail (highly OT).

Jon Gorman

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