 |
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
|
|
|

November 2nd, 2004, 04:04 AM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
xsl:apply-templates on Variable containing xml
I have a external function that produces xml.
I put the xml from the function in a varible. Is it possible to apply templates on the variable, to process the xml its containing.
Is there any way to load xml, other than from a file that is possible with document()
Regards Daniel
|

November 2nd, 2004, 05:06 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Quote:
quote:Originally posted by nexus5
I have a external function that produces xml.
I put the xml from the function in a varible. Is it possible to apply templates on the variable, to process the xml its containing.
|
Not sure what you mean, if the variable is a nodeset then it sounds possible, can you show an example?
Quote:
quote:
Is there any way to load xml, other than from a file that is possible with document()
|
Use an extension function. What parser are you using?
--
Joe (Co-author Beginning XML, 3rd edition)
|

November 2nd, 2004, 05:15 AM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Joe!
Im useing the standard java parser.
example
-------
<xsl:variable name="nr" select="./AutoListMovie/@nr" />
<xsl:variable name="d" select="./AutoListMovie/@d" />
<xsl:variable name="test" select="xhtmlStreaming:getLinkList($nr $d)" />
-------
I call a static java method (getLinkList) that does a database search and produces an xml. I put the result in a variable, but i guess its not a node set. Is it possible to generate a nodeset in any way, for other sources than from a file, like document() does?
Regards
Daniel
|

November 2nd, 2004, 07:13 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
I'm not really up to speed on Java XML. You can use document function combined with a custom UriResolver that will intercept calls made by document and replace pass in your document.
Or you can make sure that $test is converted to a node-set using an extension function.
I'm sure Java parser has such a function but I don't know what it is, in Msxml2 it is msxsl:node-set().
--
Joe (Co-author Beginning XML, 3rd edition)
|

November 2nd, 2004, 01:38 PM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The node-set() extension isn't a part of standard java, which I'm useing. I know it is in saxon and other parsers, but i haven't got time to install, so i came up with a workaround that will have to do for now.
Tanks for your help!
Regards
Daniel
|

November 2nd, 2004, 02:01 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Anything that uses Java extension functions is likely to be processor dependent. However, if the function returns a node in a tree then it's likely you will be able to do apply-templates on it.
If the extension function is constructing a new tree, then a better bet might be to use the document() function, with some URI that your URIResolver can intercept to return a Source representing the new document.
Michael Kay
Michael Kay
http://www.saxonica.com/
|

November 2nd, 2004, 02:28 PM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Im pretty new to java, its my first application.
Michael, do you know what type of object my method should return? I've tried to return a Node and a NodeList-object, and then apply-template. None of them worked.
Do you know how to rewrite the URI-resolver?
Daniel
|

November 2nd, 2004, 03:57 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
As I say, it's processor dependent. I don't think you've said what processor you are using. And you really haven't given enough information for anyone to be able to see what you are doing wrong. You haven't even said what error message you are getting!
Writing a URIResolver is more likely to be portable across processors.
It would also be a good idea to explain what you are trying to achieve. I may not need extension functions at all.
Michael Kay
Michael Kay
http://www.saxonica.com/
|

November 2nd, 2004, 04:34 PM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When the code is under development its running on a powerbook G4 Mac. Live i guess it'll run on a Sun solaris 450.
I don't get any error messages at all, what i know of. It parses fine, with no exception, but the part this discussion is concerning doesn't display anything. I'll look into the logs more thoroughly tomorrow.
What I want to achieve.
When the parser comes to a specific xml-tag i want to include a list of links to movieclips. The information of which movieclips to include is not in the xml, Im parsing. Therefore i call a static java method that does a database search , builds an xml and returns a node to the tree. The tag that triggs the method tells the method from which department and how many links to fetch.
example
-------
<xsl:variable name="nr" select="./AutoListMovie/@nr" />
<xsl:variable name="dep" select="./AutoListMovie/@dep" />
<xsl:variable name="test" select="xhtmlStreaming:getLinkList($nr $dep)" />
-------
Lets say the java-method returns something that is parseble. How do i do an apply-template on the tree?
|

November 4th, 2004, 02:55 PM
|
Authorized User
|
|
Join Date: Nov 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
?? stupid guess:
<xsl:apply-templates select="$test"/> or
<xsl:apply-templates select="document($test)"/>
won't work on xslt 1.0
|
|
 |