Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] node functions

From: Sarkup Sarkup <sarkups@--------->
To:
Date: 8/5/2008 3:48:00 PM
> From: Michael Kay <mike@xxxxxxxxxxxx>
> Subject: RE: [xsl] node functions
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Date: Tuesday, August 5, 2008, 3:20 PM
> 
> Your source document doesn't have any attributes on pub
> elements: but it
> does have an element called level1 which is the parent of
> the pub element.
> Are you confused, or are you just trying to confuse the
> rest of us?

element <pub> can occur anywhere after <info> in the xml. Here is the example with the attribute level to pub. 
--------------------------------------------------
<test2>
<info>
 <requirement>
 <level1>
 <para></para>
<pub level="1"></pub>
 </level1>
 </requirement>
 </info>
 </test2>

--------------------------------------------------


> > I tried:
 
> > This is obv wrong because the processor complains
> about it.
> 
> 1. not() is a function call, therefore it requires round
> brackets ()
> 
> 2. a filter predicate is always written in square brackets.
> 
> 3. both kinds of brackets have to match up!
> 
> So that corrects the grammar to:
> 
> //info[not(self::pub[@level='1'])]

That was a typo. Sorry about that. 

> 4. An info element will never be a pub element, so you
> don't want the self::
> axis here, you want some other axis. In your example pub is
> nested several
> layers below info - but that pub element doesn't have a
> level attribute, so
> perhaps your source document isn't useful as a guide.

Please see the new example above. 

> 5. If the select attribute of apply-templates doesn't
> select anything, then
> it does nothing, so you don't need to test it first in
> an xsl:if or
> xsl:choose.
> 
> 6. You might be better off applying templates to all the
> elements, and
> having different template rules to process those with
> level="1" and those
> with a different level.

Thank you. I will try that.


--- On Tue, 8/5/08, Michael Kay <mike@xxxxxxxxxxxx> wrote:

> From: Michael Kay <mike@xxxxxxxxxxxx>
> Subject: RE: [xsl] node functions
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Date: Tuesday, August 5, 2008, 3:20 PM
> > file2.xml
> > <test2>
> > <info>
> > <requirement>
> > <level1>
> > <para></para>
> > <pub></pub>
> > </level1>
> > </requirement>
> > </info>
> > </test2>
> > 
> > 
> > So, info and pub are two common elements between there
> two 
> > xml files. So there is a common style sheet just for
> pub 
> > called pub.xsl. pub has an attribute level which can
> be set to 1~4.
> > But in one commong style sheet, I want to apply
> templates for 
> > all //info elements and not include //pub elements
> which have 
> > @level='1'
> 
> Your source document doesn't have any attributes on pub
> elements: but it
> does have an element called level1 which is the parent of
> the pub element.
> Are you confused, or are you just trying to confuse the
> rest of us?
> > 
> > I tried:
> > 
> > <xsl:choose>
> > <xsl:when
> test="//info(not[self::pub[@level='1']">
> > 
> > <xsl:apply-templates
> select="//info(not[self::pub[@level='1']">
> > </xsl:when>
> > </xsl:choose>
> > 
> > This is obv wrong because the processor complains
> about it.
> 
> 1. not() is a function call, therefore it requires round
> brackets ()
> 
> 2. a filter predicate is always written in square brackets.
> 
> 3. both kinds of brackets have to match up!
> 
> So that corrects the grammar to:
> 
> //info[not(self::pub[@level='1'])]
> 
> 4. An info element will never be a pub element, so you
> don't want the self::
> axis here, you want some other axis. In your example pub is
> nested several
> layers below info - but that pub element doesn't have a
> level attribute, so
> perhaps your source document isn't useful as a guide.
> 
> 5. If the select attribute of apply-templates doesn't
> select anything, then
> it does nothing, so you don't need to test it first in
> an xsl:if or
> xsl:choose.
> 
> 6. You might be better off applying templates to all the
> elements, and
> having different template rules to process those with
> level="1" and those
> with a different level.
> 
> Michael Kay
> http://www.saxonica.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent