473,795 Members | 3,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(not) evaluating a document name and a path in xslt

Hi,

suppose I get a document name a.xml and a path //foo/bar (which nodes
eventually to read from it) from another doc.

Problem: how to combine them so that the whole expression gets
evaluated. I've tried:

<xsl:variable name="imported" select="concat( document('$doc' ),$path)"
/>

But this makes the value of imported [a sequence of linefeeds]
//foo/bar.

Another possibility:
<xsl:for-each select="xalan:e valuate(concat( document('$doc' ),$path))">

...does not seem to work: the $path is ok but probably the
document('$doc' ) part is still a sequence of linefeeds so as a whole
the expression is meaningless.

Is there any way of defining "set the value of the variable to be
document('$doc' ) but do not evaluate it yet"?

Marko

Mar 23 '06 #1
6 2401

markoniinimaki wrote:
suppose I get a document name a.xml and a path //foo/bar (which nodes
eventually to read from it) from another doc.


Not sure I've read your question quite carefully enough, but what's
wrong with this?
<xsl:variable name="imported" select="documen t ($doc)//foo/bar" />

Mar 23 '06 #2
> Is there any way of defining "set the value of the variable to be
document('$doc' ) but do not evaluate it yet"?


<xsl:variable name="test">doc ument('$doc')</xsl:variable>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Mar 23 '06 #3
Hi,

thanks for your answer. However, the following code

<xsl:variable name="nfile">y1 980.xml</xsl:variable>
<xsl:variable name="ndoc">doc ument('$nfile') </xsl:variable>
<xsl:value-of select="$nfile"/>
<xsl:value-of select="$ndoc"/>

results:
y1980.xml
document('$nfil e')

Marko

Mar 23 '06 #4


markoniinimaki wrote:
<xsl:variable name="nfile">y1 980.xml</xsl:variable>
<xsl:variable name="ndoc">doc ument('$nfile') </xsl:variable>
<xsl:value-of select="$nfile"/>
<xsl:value-of select="$ndoc"/>

results:
y1980.xml
document('$nfil e')


Perhaps you want e.g.
<xsl:variable name="nfile" select="'y1980. xml'" />
<xsl:variable name="ndoc" select="concat( 'document(&quot ;', $nfile,
'&quot;)')" />

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 23 '06 #5
Hi,

<xsl:variable name="imported" select="documen t ($doc)//foo/bar" />

could work but "//foo/bar" is a variable. Thus concat($docvar, $pathvar)
does not work.
xalan:evaluate( concat($docvar, $pathvar)) could work but seemingly does
not..

It might be possible to refer to "docvar" by using a namespace. Is
there a way of forcing a new namespace for a file that streams trough
the processor ("-IN" file in xalan)?

Marko

Mar 23 '06 #6

markoniinimaki wrote:
could work but "//foo/bar" is a variable.


OK, that's hard (more than I can think of offhand)

But you can use a cascade of individual "name()=$fo o" which will work
for dynamic selections

Mar 23 '06 #7

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

Similar topics

3
2126
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim is to process the contacts in a single-pass XSLT process. That is why the "document()" function is what I need. I call the "document()" XPath function from a "for-each" instruction.
1
3685
by: Bartek | last post by:
Hello This is my problem: It consider xml 2 xml conversion. source document had unknown structure (xhtml), xslt must process every node, attribute, text, comments etc. from source and write in destination file. During that process i must catch some nodes (e.g. <input> position of this node in XML tree is unknown )and change the value attribute. The destination xml file must be the exact copy of source file + changes on
14
12194
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following line in xslt <xsl:value-of select="/blah/q" /> and my xml document does not have a node /blah/q. The output would
7
2036
by: Jan Roland Eriksson | last post by:
I'm posting a revised version of the meta FAQ for this NG. Beware that there are a few links in there that does not have a resource available for them yet but, over and all, this following document should be usable as presented. Rip it apart at your own discretion... ===== Archive-name: www/stylesheets/newsgroup-faq
4
4820
by: Asbjørn Ulsberg | last post by:
Sorry for posting to a lot of groups, but I'm not sure what this problem relates to, so I thought it was better to be safe than sorry. Please feel free to set FUT to the proper group when answering. I'm having problems with the XSLT function 'document()' after upgrading to ASP.NET 1.1. I've started using XmlUrlResolver in the xslt.Transform() method, but it doesn't seem to help in all cases.
6
1890
by: Maxim Kazitov | last post by:
Hi, I try to use document() function in XSLT, but looks like .Net XSLT parser don't try to resolve external URL. Does any body know what can be wrong here : =================C#========================== public class XmlUrlResolverExt:XmlUrlResolver { private static readonly ILog log = LogFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
24
2762
by: John Rivers | last post by:
ASPX which means ASPX pages, the code-behind concept, User Controls, Web Controls etc. is very poorly designed and makes it extremely hard to develop professional quality web applications. ASPX is Microsoft's attempt to "dumb down" web application development to help unskilled developers such as web design agencies achieve some results. For high quality applications IHttpHandlers are the way to go.
6
14221
by: Jody Gelowitz | last post by:
I have run into an issue with variable scope within an XSLT document that is translated in VS.NET 2.0. Under VS.NET 1.1 (XslTransform), this code works fine. However, when using VS.NET 2.0 (XslCompiledTransform), the exact same XSLT transformation fails with the error: System.Xml.Xsl.XslLoadException: The variable or parameter 'lastrecordwaskit' was duplicated within the same scope. An error occurred at (174,12). at...
0
2395
by: super.raddish | last post by:
Greetings one and all, I have a single source XML file and I am parsing the "records" within it into separate XML files using xsl:result-document. All that works fine. I am using the Saxon engine and I am supplying the .Transform() with a Target File path which it is using to create an empty file (as it is currently unused). So I end up with, say, 50 new XML flies and 1 empty XML file at the path of the Target File <stylesheet>
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10437
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.