Skip to main content

template match

2 replies [Last post]
mohitanchlia
Offline
Joined: 2006-04-24
Points: 0

I am running JAXP to transform xml. I have following xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>

Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985

Hide your heart
Bonnie Tyler
UK
CBS Records
9.90
1988

Greatest Hits
Dolly Parton
USA
RCA
9.90
1982

Still got the blues
Gary Moore
UK
Virgin records
10.20
1990

When I use below xml I get only one result (one row);

My CD Collection

Title
Artist

I don't understand why would it give only first title and artist for the given xml. But, when I change the "match" to "catalog/cd" then I get all the elements. So for below xsl I get everything:

<?xml version="1.0" encoding="ISO-8859-1"?>

My CD Collection

Title
Artist

I don't understand why ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mohitanchlia
Offline
Joined: 2006-04-24
Points: 0

I think I know why this is happening. I just needed to understand xslt little better. Correct me if I am wrong, I think this happens because there is only one root node and since templates are rules for current node it matches root node only once because there is only one root node for a document.

joehw
Offline
Joined: 2004-12-15
Points: 0

Yes, match="/" selects from the root node.