[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: Digest Issue 664 - How to adress ... and Asse
> I'm sorry to say I didn't get the function to work, the oxygen 7 > rejected an undefined position. In general if you pick up some untested syntax from some bloke on a mailing list and your language parser tells you it has a syntax error, you should believe your parser:-) Sorry about that, I thought you were probably using xslt1 so I just threw in a few hints of goodies available in xslt2 and didn't actually test them. They were basically OK but had a few "features" that would stop them running as written. > I'm sorry to say I didn't get the function to work, the oxygen 7 rejected an undefined position. A user defined function does not automatically pick up the current node, you have to pass it explicitly, so that should be <xsl:function name="f:property" as="xs:string"> <xsl:param name="here" as="element()"/> <xsl:param name="x" as="xs:string"/> <xsl:sequence select="string($here/(@*|*)[local-name()=$x][1])"/> called as ..../f:property(.,'zzz') that is you have to pass in . explictly as a first argument so that the relative path (*|@*) in the function body works relative to the node current outside the function call. > BTW: to which URI is the f namespaceprefix bound? anything you like (but it has to be something) user defined functions in xslt2 have to be in a namespace but as long as it isn't a reserved namespace (like the one for xsl) it doesn't matter at all which namespace it is. If you were writing a libary of functions for global use you'd probably pick some stable global URI that guaranteed unique names, but for one-off namespaces in a stylesheet I usually use xmlns:f="data:,f" the data: uri type (which actually works in mozilla) just returns itself as data, so is the text "f" here. > This also works put this way: > <xsl:value-of select="$lookup/a[@code=$code]"/> yess code is an attribute so needs @, sorry. but you sorted that out. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|