473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

including xml file in xslt?

hi..

i'm trying to figure out if i can include an extenal file of xml inside
xslt, what i need is a configuration file which xslt can query duing
transformation, (we are talking about a rather large document here.
i thought about using document function, since i'm gonna thiis called
about hunders of times i don't know the impact this would have on
performance (does xsll keeps opening closing a file?)

May 8 '06 #1
7 1286
> i thought about using document function, since i'm gonna thiis called
about hunders of times i don't know the impact this would have on
performance (does xsll keeps opening closing a file?)


Odds are that most XSLT processors will cache documents referenced by
document() -- it's the easiest way to implement some of the
unique-identity requirements. If you want to make sure it gets cached
you could do a single document() call and assign to a (global?) variable.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
May 8 '06 #2

Elhanan wrote:
i thought about using document function, since i'm gonna thiis called
about hunders of times i don't know the impact this would have on
performance


The standards don't specify performance-critical behaviours like that -
so whatever you do, build a simple benchmark first and measure it. It
rarely takes long to do, in the overall project complexity.

May 8 '06 #3
thanks you mean assign it to a global variable and then do all my xpath
queries on that var? how can i do that?

now i have a much bigget problem, i'm trying to parse my xsl file with
xpath query, to remove certian bits, now i find out i cannot do any
xpath queries at all!

i look over at the samples and copied but still it doesn't work.
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
DocumentBuilder b= f.newDocumentBuilder();
org.w3c.dom.Document doc=b.parse("ATmap.xml");

XPathFactory xp=XPathFactory.newInstance();
XPath xpa=xp.newXPath();
xpa.setNamespaceContext(new MyNamespaceContext());

XPathExpression xe=xpa.compile("//foo:document");

Node when =(Node)xe.evaluate(doc,XPathConstants.NODE);
System.out.println(when);
}catch (Exception e){
e.printStackTrace();
}

and the xml is:
<?xml version='1.0'?>
<foo:document xmlns:foo="http://apache.org/foo"
xmlns:bar="http://apache.org/bar">
<bar:element>MyBar</bar:element>
</foo:document>

and yet i keep getting null!!, i'm going crazy here.

May 8 '06 #4
never mind got it, i should have place
setNameSpaceAware()!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!

May 8 '06 #5
Elhanan wrote:
thanks you mean assign it to a global variable and then do all my xpath
queries on that var? how can i do that?


<xsl:variable name="something" select="document('foo.xml')/stuff"/>

///Peter
--
XML FAQ: http://xml.silmaril.ie/
May 8 '06 #6
yea but how do i xpath on that variable?

May 10 '06 #7
Elhanan wrote:
yea but how do i xpath on that variable?


If the variable contains a nodeset, you can use it as the root of an
XPath -- $foo/bar/baz[@murph] or whatever to start your search from the
nodes in variable $foo.

If it contains a Result Tree Fragment (RTF), you need to use the EXSLT
nodeset function (or whatever equivalent your processor supports) to
turn it into a nodeset first; then proceed as above.

Note that in XSLT 2.0, the distinction between those two goes away; any
expression that returned one or the other will return a Temporary Tree,
which can be used in expressions the way nodesets are in 1.0.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 10 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fredrik Henricsson | last post by:
Hey, I'm building an ontology in Protégé and I want to transform parts of it (e.g. the instances) to HTML with XSL. When I was transforming another file with 'simple' XML-tags like <author> before,...
5
by: hilz | last post by:
Hi, I am trying to style an rss feed. i created a stylesheet, and an xml file. i include the stylesheet and the rss feed file into my xml file. when i open my xml file in IE, everything works...
2
by: Marcelo | last post by:
Hi Guys, I have the following question. I have a Xerox DJDE File that I want to convert to PDF.
4
by: dar_imiro | last post by:
Hi, I'm trying to get rid of frames as menu holder in my html-page. I'd also like to separate the menu structure to xml and xslt. Also the actual content is divided to xml and its corresponding...
2
by: griffithsj_520 | last post by:
I have to create a web page to give to clients that is shipped on CD. The idea is that they would open the page and it would display in their web browser. What this will do is to provide a list...
6
by: Lenny Wintfeld | last post by:
Hi I'm attempting additions/changes to a Java program that (among other things) uses XSLT to transform a large (96 Mb) XML file. It runs fine on small XML files but generates OutOfMemory...
3
by: danmc91 | last post by:
Hello, I'm new to xml and xslt but that should be obvious from my question. I'm trying to help my wife set up some web pages with some of her art work and what I'm trying to do is find a way...
20
by: Johan | last post by:
How can I include one XML file into another XML file (on the client side, in Firefox)? I think XInclude is just what I need, but Firefox doesn't support it:...
2
by: Cameron.MacNeil.024 | last post by:
Hi folks, hopefully I posted this question in the right place. I'm currently writing an html file which references three different xml files, each one with its own xsl stylesheet. Originally I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.