Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 11th, 2006, 03:34 AM
Authorized User
 
Join Date: Jun 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
i have another question :
i have this code :

Code:
<xsl:for-each-group select="*" group-ending-with="if|expr_stmt[expr/call[name=$grab/*[name()='call']]]">

....

<xsl:value-of select="current-group()[name()!='if' and name()!='decl_stmt']" />
i want to add the condition that it must not include the expr_stmt that contain items listed in $grab. unfortunately, i cannot use the same expression ad in group-ending-with because here we use name() and a string must be supplied. i cannot do name()!='expr_stmt'[...] any ideas of how to do that ? i tried the function node() but doesn't seem to work. i don't know its exact behavior.

Thanks in advance.

 
Old July 11th, 2006, 03:44 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

IIRC, I came to the conclusion that the reason you were using $grab/*[name()='call'] rather than $grab/call was that you had namespaces in scope that you weren't showing me. Please bite that bullet, and use $grab/x:call where x is bound to the correct namespace.

But I think (more groping in the dark, it's so much easier when people show you the code) that "if" and "expr" and perhaps "decl_stmt" are not in any namespace.

so you should be able to do

<xsl:value-of select="current-group[not (self::if or self::decl_stmt or self::expr_stmt[expr/call[name=$grab/x:call]])]"

Why not write yourself a function:

<xsl:function name="f:final" as="xs:boolean">
  <xsl:param name="n" as="node()"/>
  <xsl:param name="grab" as="element()"/>
  <xsl:sequence select="self::if or expr_stmt[expr/call[name=$grab/x:call]]">
</xsl:function>

then

group-ending-with="f:final(.)"

and you can reuse the function in your value-of test.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 11th, 2006, 04:09 AM
Authorized User
 
Join Date: Jun 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again and thank you for your response.
the <call> is not bound to any namespace i have :

<xsl:variable name="grab">
  <call>main</call>
  <call>foo2</call>
</xsl:variable>

maybe you're right saying that if, ... are not bound to any namespace. the generated C -> XML file has this header :

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<unit xmlns="http://www.sdml.info/srcML/src" xmlns:cpp="http://www.sdml.info/srcML/cpp" language="C++">

but in order to process it with XSLT, i had to add a prefix : <x:unit xmlns:x=...>

in my stylesheet, i have :

<xsl:stylesheet
  xmlns="http://www.sdml.info/srcML/src"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:cpp="http://www.sdml.info/srcML/cpp"
  xmlns:c2sig=""
  version="2.0">

is it right ?
i have a function named c2sig, why should it have a prefix ?

the condition : not (self::if or self::decl_stmt or self::expr_stmt[expr/call[name=$grab/x:call]])] worked fine. thanks a lot again.

 
Old July 11th, 2006, 04:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If your stylesheet starts

<xsl:stylesheet
  xmlns="http://www.sdml.info/srcML/src"

and then has

<xsl:variable name="grab">
  <call>main</call>
  <call>foo2</call>
</xsl:variable>

then the <call> elements are in namespace http://www.sdml.info/srcML/src.

All stylesheet functions need to be declared in a namespace to distinguish them from system functions. It's just one of those rules.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Appending set of elements after the similar nodes sesath XSLT 2 May 15th, 2007 10:16 AM
template match doesnt match the required node Tomi XSLT 2 March 12th, 2007 06:24 AM
Match by attribute. ole_v2 XSLT 6 November 11th, 2006 10:24 AM
Match records bram_code VB Databases Basics 1 May 5th, 2006 10:36 AM
match containing variable csbdeady XML 1 October 25th, 2004 05:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.