OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: about saxon

[ Lists Home | Date Index | Thread Index ]
  • From: Kay Michael <Michael.Kay@icl.com>
  • To: "'Huaxin Zhang'" <hxzhang@cs.ualberta.ca>, unlisted-recipients <unlisted-recipients:@x400.icl.co.uk;>
  • Date: Wed, 7 Jun 2000 10:15:32 +0100

> I am new at XML. Somebody told me SAXON is considered better 
> than SAX and DOM. Because users can make use of the "event-rule-action" 
> model. However, this feature is pretty vague to me.

Saxon is now used mainly as an XSLT processor, but in its original form it
was just a Java class library for processing XML files, and it can still be
used this way if you want. The processing model is (of course) very similar
to the XSLT processing model: you declare a set of handlers (Java classes)
to process the nodes that match a particular pattern. Then you
start processing at the root node: the handler for the root node will
typically call applyTemplates() to trigger processing of its child nodes,
each using its own handler, and so on.
> 
> First, there is no event, the examples are just setting 
> elemnent handlers to specified tags. If I want something like "once there
are 
> three <task> objects with the same "user" attribute, do something, how can

> I set this rule? (or even with any XML tools you know)

As with XSLT, you can only define patterns that an individual node must
satisfy, there is no way of matching a sequence of nodes. However, the
patterns are quite powerful, for example the pattern
"task[not(@user=preceding-sibling::task[1]/@user)]" matches any <task>
element except one whose user attribute is the same as the user attribute of
the immediately preceding <task> element.

The "event" is that a handler calls applyTemplates(), this causes a set of
nodes to be selected, for each one the appropriate handler is selected
according to its match pattern, and this handler is then fired off.

(At one time SAXON worked serially through the document, so handlers were
fired off automatically as SAX events occurred. This was later changed to a
more navigational model in line with the XSLT specification)
> 
> Another question is :
>  I want to have a XML containing a lot of <task/>, each have
> a taskID, I want to get a int[] returned from the 
> "Expression", but seems this is not doable. How shall I get all the sets
to an array?

You can get a node-set containing all the taskID attribute nodes using the
XPath expression task/@taskID; you can then convert this node-set into an
int[] in your own Java code.

Mike Kay
 

***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@xml.org&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS