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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Sorting Problem-Thanks

[ Lists Home | Date Index | Thread Index ]

Thanks Mike,
It was a great help.Atleast it help me resolved
another basic issue.I'm getting the right data now and
I guess I'm also fine with the sorting problem.
Thanks a ton everyone.U are all a big help.This list
is amazing.
I'm working on  grouping problem now.I might have to
post my problems again on the list to buzz u guys.
Regards and thanks a lot,
Puja.


--- Mike Fitzgerald <mike@wyeast.net> wrote:
> What's happening when you get data you're not
> selecting is that the
> processor is invoking built-in template rules. To
> fix this you have to use
> specific template rules or template rules that
> simply turn off the built-in
> rules.
> 
> Here's the trick. When xsl:template matches a
> pattern, it processes all the
> children of the pattern; however, if you use a
> xsl:apply-templates child, it
> searches the stylesheet for other templates that
> match the children of the
> pattern. If another template exists that matches a
> child of the pattern,
> usually it will not invoke the built-in rules. For
> example, play with
> something like this:
> 
> C:\XML\Examples>cat test.xml
> <rootdata>
>  <child1>1</child1>
>  <child2>2</child2>
> </rootdata>
> 
> C:\XML\Examples>cat test.xsl
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="text"/>
> 
> <xsl:template match="rootdata">
>  <xsl:apply-templates select="child1"/>
> </xsl:template>
> 
> <xsl:template match="child1">ch1: <xsl:value-of
> select="."/></xsl:template>
> 
> </xsl:stylesheet>
> 
> C:\XML\Examples>xalan test.xml test.xsl
> ch1: 1
> C:\XML\Examples>
> 
> Comment out the second template in test.xsl and see
> what happens. Also,
> comment out the xsl:apply-templates element in the
> first template and see
> what happens. This will help you understand template
> behavior better.
> 
> Best of luck,
> 
> Mike
> 
> 
> > -----Original Message-----
> > From: puja thakral [mailto:puja_thakral@yahoo.com]
> > Sent: Friday, October 17, 2003 7:25 AM
> > To: Mike Fitzgerald
> > Subject: RE: [xml-dev] Sorting Problem
> >
> >
> > Thanks for u'r reply guys.
> >
> > But the thing is that it'll be a little time
> consuming
> > if I've to change the things in my XML document.
> > Because I'm pulling it directly from a huge
> database
> > which has thousands of entries.
> >
> > Second thing is when I tried to use <xsl:template
> > match> instead of <xsl:for-each select>,I get the
> data
> > from my xml file which I'm not even selecting in 
> my
> > stylesheet to be displayed.That data is being
> > displayed randomly along with other data.
> >
> > Regards and thanks a lot for all the help,
> > Puja
> >
> >
> >
> > --- Mike Fitzgerald <mike@wyeast.net> wrote:
> > > Puja,
> > >
> > > xsl:template matches patterns; xsl:for-each is a
> > > child of xsl:template that
> > > iterates nodes within that pattern, depending on
> the
> > > value of select.
> > > xsl:for-each may not be what you want. Try
> something
> > > like this (I mocked up
> > > your source elements):
> > >
> > > C:\XML\Examples>cat puja.xml
> > > <dataroot>
> > >  <GrantNet fldCatID="x001">1</GrantNet>
> > >  <GrantNet fldCatID="x003">3</GrantNet>
> > >  <GrantNet fldCatID="x006">6</GrantNet>
> > >  <GrantNet fldCatID="x005">5</GrantNet>
> > >  <GrantNet fldCatID="x002">2</GrantNet>
> > >  <GrantNet fldCatID="x004">4</GrantNet>
> > >  <GrantNet fldCatID="x007">7</GrantNet>
> > > </dataroot>
> > >
> > > C:\XML\Examples>cat puja.xsl
> > > <xsl:stylesheet version="1.0"
> > >
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> > > <xsl:output method="text"/>
> > >
> > > <xsl:template match="dataroot">
> > >  <xsl:apply-templates select="GrantNet">
> > >   <xsl:sort select="@fldCatID"/>
> > >  </xsl:apply-templates>
> > > </xsl:template>
> > >
> > > </xsl:stylesheet>
> > >
> > > C:\XML\Examples>xalan puja.xml puja.xsl
> > > 1234567
> > > C:\XML\Examples>
> > >
> > > I can't be sure of what you want without seeing
> your
> > > source document. Good
> > > luck.
> > >
> > > Mike
> > >
> > > > -----Original Message-----
> > > > From: puja thakral
> [mailto:puja_thakral@yahoo.com]
> > > > Sent: Thursday, October 16, 2003 9:07 AM
> > > > To: List; xml
> > > > Subject: [xml-dev] Sorting Problem
> > > >
> > > >
> > > > Hi everyone,
> > > > I'm also having sorting problems.I'm using
> > > >
> > > > <xsl:for-each select="dataroot/GrantNet">
> > > > <xsl:sort select="@fldCatID"/>
> > > > </xsl:for-each>
> > > >
> > > > this code to sort my items by fldCatID but it
> > > doesn't
> > > > seems to work.
> > > >
> > > > I also have one more question.I'm still
> learning
> > > > xml/xsl.What is the difference between using
> > > > <xsl:for-each select> and <xsl:template match>
> > > > I tried using both of them but some functions
> seem
> > > to
> > > > work in one and not in another.Can someone pls
> > > clarify
> > > > the basic question.I'm sorry if u find this
> > > question
> > > > too dumb but there is noone working on this in
> my
> > > > office whom I can ask?Also I could not find a
> > > > convincing answer by searching on Google.
> > > > Thanks guys,
> > > > Puja
> > > >
> > > > __________________________________
> > > > Do you Yahoo!?
> > > > The New Yahoo! Shopping - with improved
> product
> > > search
> > > > http://shopping.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!?
> > The New Yahoo! Shopping - with improved product
> search
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com




 

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

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