Re: dynamic node selection

2003-07-23 Thread Adam Flegman
Hi Tony,

 xsl:template name=createOptionList
xsl:param name=parentNode select=string() /
xsl:param name=childNode select=string() /
 
xsl:variable 
 name=targetNode 
 select=concat(name($listNode),'/',$listItem) /
 
 
xsl:for-each select=$targetNode 
... do the processing 
/xsl:for-each
 
 
 Any advice, greatly appreciated.
   
 
 
 
 
 Adam,
 
 I'm not too sure what you're trying to do. Are you trying to create an 
 element named with the value of $targetNode? Or are you trying to apply 
 your templates to the nodes named in the value of $targetNode?
 
 If all you're trying to do is create a new named $targetNode, all you'd 
 have to do is:
 
  xsl:element name=$targetNodefoo/xsl:element
 
 So, again, I'm not to sure what you're trying to accomplish.. perhaps an 
 xslt list can help.
 
 Tony
 

My apologies for the lack of clarity. I was trying to use the value I have
calcualted for the $targetNode variable to select a node in my XML document.

If I had an xml source like the following, I would like to be able to
'dynamically' select nodes for processing.

root
   foo
  bar /
  bar /
  bar /
   /foo

   dog
  eatcat /
  eatcat /
  eatcat /
   /dog
/root


The xslt template to do the processing:

xsl:template name=createOptionList
   xsl:param name=parentNode select=string() /
   xsl:param name=childNode select=string() /

   xsl:variable 
name=targetNode 
select=concat(name($listNode),'/',$listItem) /

   xsl:for-each select=$targetNode 
   ... do the processing 
   /xsl:for-each
/xsl:template

For example if parameters parentNode = foo and childNode = bar, then
$targetNode would evaluate to the string foo/bar. I would want the 'for-each'
statement to select all the bar nodes under the foo parent node.

I think the only step I am missing is how to write a xpath node selection query
that can take a string parameter as its argument.


Thanks for your time Tony.


Ad.


=
Adam Flegman - Senior Software Engineer

Mobile: (0414) 375 735
Phone: (07) 5547 8530
Facsimile: (07) 5547 8532
Email #1: [EMAIL PROTECTED] 
Email #2: [EMAIL PROTECTED]

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: dynamic node selection

2003-07-23 Thread Adam Flegman
 Well, if you have your xpath in $targetnode, wouldn't it simply be:
 
 xsl:apply-templates select=$targetnode/?
 
 or
 
 xsl:for-each select=$targetnode
 xsl:apply-templates/
 /xsl:for-each
 
 To go along with your code.   I haven't done XSLT in a while, so I'm a 
 little rusty.
 
Hi Tony,

The value of $targetNode is some arbitrary string value that (hopefully) looks
like an xml node path. At design time I dont know all the possible values that
the $targetNode string may have. 

I have tried to use the xsl:for-each select=$targetNode approach but it
seems that the 'select' part doesnt like using a string parameter. I get the
following error report from cocoon:


Exception in creating Transform Handler 

More precisely:

org.apache.cocoon.ProcessingException: Exception in creating Transform Handler:
java.lang.NullPointerException



If I could find a way to take the string value of $targetNode and actually
select the corresponding nodes then I think the problem is solved.


Ad.

=
Adam Flegman - Senior Software Engineer

Mobile: (0414) 375 735
Phone: (07) 5547 8530
Facsimile: (07) 5547 8532
Email #1: [EMAIL PROTECTED] 
Email #2: [EMAIL PROTECTED]

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: dynamic node selection

2003-07-23 Thread Adam Flegman
--- Conal Tuohy [EMAIL PROTECTED] wrote:
 Adam there's no dynamic xpath expression evaluation in XSLT - you'll
 probably want to find some other way to identify the nodes you want to deal
 with since writing a generic xpath evaluator in XSLT is not going to be easy.
 It would be feasible though to parse some standard type of expressions rather
 than any arbitrary xpath. e.g. if you could ensure that all the xpaths were
 like: foo[1]/blah[2] - but this may not be feasible since you say you don't
 know the possible values that your xpath expression may have? Where do they
 come from?

Hi Conal,

I was getting the feeling that this was the case (i.e no dynamic xpath
evaluation). I guess I have to go back and look at other ways to achieve a
similar result.

Thanks again to you and Tony for your help.



Regards,

Adam.

=
Adam Flegman - Senior Software Engineer

Mobile: (0414) 375 735
Phone: (07) 5547 8530
Facsimile: (07) 5547 8532
Email #1: [EMAIL PROTECTED] 
Email #2: [EMAIL PROTECTED]

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: dynamic node selection

2003-07-23 Thread Adam Flegman
 Have you tried using name() function like:
 
 xsl:apply-templates
 select=/*[name()=$parentNode]/*[name()=$childNode]/
 
 However, as far as I know name() function is there for
 emergency cases, rather than normal usage.
 
 If you know what the nodes might be, you might want to
 use several stylesheets and pick the right stylesheet
 dynamically.

Hi Alex,

In some cases I actually had the node corresponding to the parent and tried
using the name() function to match the $childNode portion but it still didn't
work.

select=$parentNode/*[name()=$childNode]

($parentNode is an actual node, $childNode was the name of the desired target
node below the parent).


I was hoping to use this approach to help cleanup/refactor some verbose xslt
code I have inheirited. Its not really a critical problem as the existing code
is functionally correct, I was just trying to tidy it up a bit.



Ad.


=
Adam Flegman - Senior Software Engineer

Mobile: (0414) 375 735
Phone: (07) 5547 8530
Facsimile: (07) 5547 8532
Email #1: [EMAIL PROTECTED] 
Email #2: [EMAIL PROTECTED]

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie In Peril

2003-07-07 Thread Adam Flegman
Thanks Nuno,

Wow it looks much simpler than what I thought it would be. 

I have to finish the client side of the site first and then get on to the
administator/maintenance side which is definitely going to require this
authorisation mechanism.

Thankyou. Thankyou. Thankyou!

You have saved me a so much time and a lot of stress.


Ad.

=
Adam Flegman - Senior Software Engineer

Mobile: (0414) 375 735
Phone: (07) 5547 8530
Facsimile: (07) 5547 8532
Email #1: [EMAIL PROTECTED] 
Email #2: [EMAIL PROTECTED]

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie In Peril

2003-07-07 Thread Adam Flegman
Hi Nuno,

I tried to reply a few moments ago but yahoo mail was in an invalid state. I
just hope you don't get 4-5 thankyou emails from me.

Your solution makes it look so simple. I was thinking it was going to be very
very hard and complicated to solve. I am only just begging to understand how
powerful the sitemap is.

I have to finish the client side of the application first before I can look at
the administrator side of the web site. The administration side will definitely
need to use the solution you have so generously provided.

Thankyou. Thankyou. Thankyou!

You have saved me so much time and stress. I hope that one day I will know
enough about cocoon to also be able to give something back to new user's of
cocoon.



Ad.

=
Adam Flegman - Senior Software Engineer

Mobile: (0414) 375 735
Phone: (07) 5547 8530
Facsimile: (07) 5547 8532
Email #1: [EMAIL PROTECTED] 
Email #2: [EMAIL PROTECTED]

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]