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

RE: Building Complex XML


complex xml file
Set up your criteria file like this:

<criteria>
<category grade="1">
  <criterion>country != 'USA'</criterion>
  <criterion>age &gt; 20 and age &lt; 25</criterion>
  <criterion>occupation = "doctor" or occupation =
"engineer"</criterion>
</category >
<category grade="2">
  <criterion>country = 'UK'</criterion>
  <criterion>age &lt; 50</criterion>
  <criterion>occupation = "dentist"</criterion>
</category >
</criteria>

This is probably as easy for your users to edit as anything is likely to
be.

Write a stylesheet that transforms this file into a stylesheet
containing code such 

<xsl:template match="Employee
     [country != 'USA']
     [age &gt; 20 and age &lt; 25]
     [occupation = 'doctor' or occupation = 'engineer']">
<p>Grade 1</p>
</xsl:template>

<xsl:template match="Employee
     [country = 'UK']
     [age &lt; 50]
     [occupation = 'dentist']">
<p>Grade 2</p>
</xsl:template>

Then run this generated stylesheet against your source XML file.

Michael Kay
Software AG
home: Michael.H.Kay@n...
work: Michael.Kay@s... 


> -----Original Message-----
> From: Nischal Muthana [mailto:nischal_muthana@y...] 
> Sent: 06 June 2002 19:39
> To: michael.h.kay@n...; xml-dev@l...
> Subject: RE:  Building Complex XML
> 
> 
> Mike
> 
> Thanks for the Reply.
> 
> >What you could do is to process the criteria
> > file by transforming
> > it into an XSLT stylesheet and then executing that  stylesheet.
> 
> If I undestand you correctly, you mean to say you want
> me to build an XSLT stylesheet which contains all of
> the criteria table. And then apply on the XML source.
> But dont you think doing this would make the user's
> life difficult in editing the criteria's whenever he
> wants to. 
> 
> And moreover can any of you provide any links to the
> XSLT resources and would more appreicate if you can
> pass any samples or links to resources for the above requirement.
> 
> Thanks
> Nischal
> 
> --- Michael Kay <michael.h.kay@n...> wrote:
> > This is an interesting one. Turning your criteria
> > into XPath expressions
> > and storing them in an XML file is the right thing
> > to do and isn't
> > difficult. Processing these using XSLT is a little
> > tricky, though,
> > because it doesn't currently handle XPath
> > expressions read from a source
> > file. What you could do is to process the criteria
> > file by transforming
> > it into an XSLT stylesheet and then executing that stylesheet.
> > 
> > Michael Kay
> > Software AG
> > home: Michael.H.Kay@n...
> > work: Michael.Kay@s...
> > 
> > > -----Original Message-----
> > > From: Nischal Muthana
> > [mailto:nischal_muthana@y...]
> > > Sent: 06 June 2002 18:08
> > > To: xml-dev@l...
> > > Subject:  Building Complex XML
> > > 
> > > 
> > > Hello All
> > > 
> > > I have an XML file with
> > <country>,<Age>,<Occupation>
> > > tags and other tags.
> > > 
> > > I have a criteria table for eg. like the
> > following:
> > > 
> > > Decision Element         Grade1				
> > > Grade2				Grade3
> > > Country		   Not equal to USA	  Not equal to 
> > > USA and UK
> > >      Equal to USA and UK	
> > > Age		   20,21,22,23,24 or 25	   48,49,50,51,52 or
> > 53	
> > > All 50 othere than 51,54
> > > Occupatioin 	   Engineer or Doctor	        Lawyer
> > or
> > > Cop		    Student or Worker		
> > > 
> > > I have a C# class which is gonna check the above
> > > conditions and makes sure the XML fulfills all of
> > the
> > > conditions in any of the Grade and returns the
> > appropriate Grade.
> > > 
> > > So for eg. if my XML contains
> > > 
> > > <Country>USA</Country>
> > > <Age>53</Age>
> > > <Occupation>Student</Occupation>
> > > 
> > > I would then return Grade3.
> > > 
> > > Everything works like a charm until here. But the
> > user
> > > came up with a proposal that he should be able to
> > edit
> > > this criterion table frequently. So we thought we
> > > would implement this also as an XML file.
> > > 
> > > Can someone please help me in goin about with
> > this.
> > > 
> > > Thanks
> > > Nischal
> > > 
> > > 
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! - Official partner of 2002 FIFA World Cup
> > http://fifaworldcup.yahoo.com
> > 
> >
> -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > initiative of OASIS <http://www.oasis-open.org>
> > 
> > The list archives are at http://lists.xml.org/archives/xml-dev/
> > 
> > To subscribe or unsubscribe from this list use the subscription
> > manager: <http://lists.xml.org/ob/adm.pl>
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup 
http://fifaworldcup.yahoo.com


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.