Re: Doubts regarding XSL and DOM

Subject: Re: Doubts regarding XSL and DOM
From: "Amit Rekhi" <amitr@xxxxxxxxxxxxx>
Date: Tue, 27 Oct 1998 11:05:42 +0530
Hi! Joe,

>>DOUBT 3 :- <...> does XSL take
>>care of all the types of traversals that DOM caters to?
>
>I'm not entirely sure why this is a concern... The question should be
>whether XSL supports all the kinds of traversal that XSL itself requires,
>unless I'm missing something.

It's the "document transformation" part that XSL achieves that makes me feel
that some kind of an object model (DOM in my case) is needed. The reason
being that any tool which can transform a source tree should also support an
object model to query the source tree.That is the reason why I was thinking
of XSL rule patterns and DOM interfaces together in XSL at the same level.

QUESTION 1:- Am I right ?

Why would I want an object model ? Simply, because in my template I may want
to query a particular element in the source tree and an object model (if
present) helps me do just that.

Let me explain my point :-
I have a sample XML file :-

<Customers>
  <Customer>
    <Name>Amit</Name>
  </Customer>
  <Customer>
    <Name>Joe</Name>
  </Customer>
   .
   .
</Customers>

I have a sample XSL file for the above XML :-

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>
  <xsl:template match="*|/ ">
     <xml:text>The tag name of the current node traversed is</xml:text>

     /*HERE I WISH TO USE AN INTERFACE THAT COULD GIVE ME THE TAGNAME OF
EACH
        ELEMENT NODE TRAVERSED IN THE SRC. XML TREE */
 </xsl:template>
</xsl:stylesheet>

In the above XSL file I have only defined a default pattern rule which will
get invoked for every element of the src. XML tree. But my requirement is
that as and when I traverse the src. XML tree I should be able to access the
current node's tagname from my template (as stated in BOLD above).

QUESTION 2:- How do I achieve the above using ONLY XSL pattern rules?

It is for such purposes that an object model will help. I could have a
"tagName" function that could give me the tag name of the current node.

Because of the above doubts I happen to ask :-

QUESTION 3:- Does XSL give us any type of object model, apart from the
pattern syntax  to query the src. XML tree for specific queries (like can be
done thru DOM)?





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread