Click here to Skip to main content
15,921,212 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: XSD ??? Pin
Michael A. Barnhart9-Sep-02 16:35
Michael A. Barnhart9-Sep-02 16:35 
GeneralRe: XSD ??? Pin
Paul Watson11-Sep-02 8:11
sitebuilderPaul Watson11-Sep-02 8:11 
GeneralRe: XSD ??? Pin
Nood!e17-Sep-02 21:57
Nood!e17-Sep-02 21:57 
AnswerRe: XSD ??? Pin
Ranjan Banerji11-Sep-02 4:09
Ranjan Banerji11-Sep-02 4:09 
AnswerRe: XSD ??? Pin
Paul Watson11-Sep-02 8:14
sitebuilderPaul Watson11-Sep-02 8:14 
AnswerRe: XSD ??? Pin
Richard Deeming12-Sep-02 5:14
mveRichard Deeming12-Sep-02 5:14 
Generalpassing a variable to xsl Pin
Thesisus7-Sep-02 16:25
Thesisus7-Sep-02 16:25 
GeneralRe: passing a variable to xsl Pin
Erik Westermann8-Sep-02 12:04
professionalErik Westermann8-Sep-02 12:04 
You can accomplish this, if you're doing this through a browser, with a little bit of processing either in the browser or on the server. In either case, the processing you do is the same. The short story is that you use an XPath expression to extract the value of the node(s) you want to display. Here are the details:

I'm going to give you details from part of an example from my soon to be available book not for name recognition, but simply because it is a good example that demonstrates the technique.

Assume that you have a site that publishes book reviews - the details of each book (title, author, etc) along with book reviews reside an an XML file that has a relative simple structure. When users hit the site, they receive a page that lists all books and provides a link to the review. The page, in one part of the sample, actually not an HTML page but is an XML file that's transformed on the client using XSL (so the URL users see in the address bar ends in a file name having an XML extension). This, so far, is the first bit of processing you need to do - transform the XML document (in your case the document that contains information about the directory) into a presentable format.

The next bit of processing occurs when the user clicks on a record (or book review in this example) to get the details. I made this part of the process easier for myself back in the previous step: I generated links that provide the information I need in this step to extract the information the user wants. In the sample, I generate links that point to an HTML page along with some information on the querystring, to the link I generate looks something like this:

<a href="displayReview.htm?Book Title">Book Title</a>

So that when the user clicks the link, displayReview.htm can extract the review from the XML file. displayReview.htm contains a little bit of JavaScript that does the following:


  1. Extracts the text passed in on the querystring.
  2. Creates an instance of the XML DOM.
  3. Loads the book reviews document into the DOM.
  4. Creates another instance of the DOM.
  5. Loads an XSL file into the second DOM.
  6. Builds an XPath expression that includes the book's title.
  7. Uses the selectSingleNode method to execute the XPath query.
  8. Uses the transformNode method to transform the resulting node into some presentable format for the end user.
  9. Stuffs the result into the content of the HTML document.


It looks rather involved here, but it is straight-forward once you see it in action. My book actually implements the sample in two ways: XML, XSL and HTML with JavaScript (this implementaiton), and ASP where all the processing is done on the server and clients receive static HTML.

Good luck!

Erik Westermann
Author, Learn XML In A Weekend (Fall 2002)
GeneralJava and XML Pin
sasdav5-Sep-02 3:44
sasdav5-Sep-02 3:44 
GeneralRe: Java and XML Pin
Ryan B.12-Sep-02 5:34
Ryan B.12-Sep-02 5:34 
GeneralXML for persisted data Pin
Jeremy Pullicino5-Sep-02 0:21
Jeremy Pullicino5-Sep-02 0:21 
GeneralRe: XML for persisted data Pin
Zdenek Navratil5-Sep-02 2:04
Zdenek Navratil5-Sep-02 2:04 
GeneralRe: XML for persisted data Pin
Ranjan Banerji5-Sep-02 5:36
Ranjan Banerji5-Sep-02 5:36 
GeneralRe: XML for persisted data Pin
Jeremy Pullicino5-Sep-02 23:44
Jeremy Pullicino5-Sep-02 23:44 
GeneralRe: XML for persisted data Pin
Erik Westermann8-Sep-02 12:20
professionalErik Westermann8-Sep-02 12:20 
GeneralRe: XML for persisted data Pin
Paul Watson5-Sep-02 6:32
sitebuilderPaul Watson5-Sep-02 6:32 
GeneralRe: XML for persisted data Pin
Jeremy Pullicino5-Sep-02 23:46
Jeremy Pullicino5-Sep-02 23:46 
GeneralRe: Pausing SVG Pin
Paul Watson5-Sep-02 3:56
sitebuilderPaul Watson5-Sep-02 3:56 
QuestionXML editor? Pin
Rickard Andersson203-Sep-02 9:07
Rickard Andersson203-Sep-02 9:07 
AnswerRe: XML editor? Pin
Philip Fitzsimons23-Sep-02 7:19
Philip Fitzsimons23-Sep-02 7:19 
GeneralRe: XML editor? Pin
Rickard Andersson2023-Sep-02 22:20
Rickard Andersson2023-Sep-02 22:20 
QuestionCDATA in element attributes? Pin
Zyxil3-Sep-02 8:43
Zyxil3-Sep-02 8:43 
AnswerRe: CDATA in element attributes? Pin
Paul Watson3-Sep-02 23:43
sitebuilderPaul Watson3-Sep-02 23:43 
GeneralGroup problem Pin
Ahmet Orkun GEDiK26-Aug-02 11:32
sussAhmet Orkun GEDiK26-Aug-02 11:32 
GeneralRe: Group problem Pin
Ranjan Banerji28-Aug-02 7:18
Ranjan Banerji28-Aug-02 7:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.