473,785 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to value-of in copy-of in document to merge ?

SIMPLE VERSION OF THE QUESTION:
XML_TO_COPY.XML
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl"
href="xsl_that_ tries_to_copy_b ut_does_not_wor k.xsl"?>
<fruits date="20060621" >
<fruit name="orange" />
</fruits>

COPY_RESULT_THA T_IS_INTENDED.X ML
orange

XSL_THAT_TRIES_ TO_COPY_BUT_DOE S_NOT_WORK.XSL
<?xml version="1.0" encoding="UTF-8"?><xsl:styles heet version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"><xsl :output
method="xml" indent="yes" /><xsl:templat e match="/">
<!-- ?!: this or something similar -->
<xsl:copy-of select="documen t('20060618.xml ')/fruits/fruit[value-of
select='@name']" />
</xsl:template>
</xsl:stylesheet>

CRYPTIC VERSION OF THE QUESTION:
I have such xml files stored by dates. On user input for a date range,
I intend to merge that many xml files and output their fruit names.

Thanks in advance.

Jun 21 '06 #1
4 1404
On Wed, 21 Jun 2006 16:27:00 +0200, vo*******@spati allink.org
<vo*******@spat iallink.org> wrote:
<xsl:template match="/">
<!-- ?!: this or something similar -->
<xsl:copy-of select="documen t('20060618.xml ')/fruits/fruit[value-of
select='@name']" />
</xsl:template>


Hi,

2 problems with this code:

1) the xpath makes no sense; I suppose you rather want this:
document('20060 618.xml')/fruits/fruit/@name
2) there's no use copying an attribute node when you haven't got an
element in the result tree that should get that attribute

I guess you just want the _value_ of the attribute copied, not the
attribute itself.
Give this a try:
<xsl:apply-templates select="documen t('20060618.xml ')/fruits/fruit/@name"
/>

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Gaudiam omnibus traderat W3C, nec vana fides
Jun 21 '06 #2
Joris,
During my previous failed attempts, the closest I got to accessing the
attribute value in some way was through this:

<xsl:copy-of select="documen t('20060618.xml ')/fruits/fruit[@name =
'orange']" />

I even tried nesting <xsl:value-of...> within <xsl:copy-of...>, but it
didn't work.

Thanks for your solution. I tried it within and without <xsl:template
match="/"></xsl:template>, but it doesn't work.

Regards,

Jun 21 '06 #3
I may not have to use xsl:copy-of. I may have to use xsl:variable.
Anyway, more failed attempts:

[1]
<xsl:template match="document ('20060618.xml' )/fruits">
<xsl:for-each select="fruit">
<xsl:value-of select="@name"/>
</xsl:for-each>
</xsl:template>

[2]
<xsl:template match="/">
<xsl:for-each select="documen t('20060618.xml ')/fruits/fruit">
<xsl:value-of select="@name" />
</xsl:for-each>
</xsl:template>

Regards,

Jun 21 '06 #4
On Thu, 22 Jun 2006 00:23:02 +0200, vo*******@spati allink.org
<vo*******@spat iallink.org> wrote:
I may not have to use xsl:copy-of. I may have to use xsl:variable.
Anyway, more failed attempts:

[1]
<xsl:template match="document ('20060618.xml' )/fruits">
<xsl:for-each select="fruit">
<xsl:value-of select="@name"/>
</xsl:for-each>
</xsl:template>

[2]
<xsl:template match="/">
<xsl:for-each select="documen t('20060618.xml ')/fruits/fruit">
<xsl:value-of select="@name" />
</xsl:for-each>
</xsl:template>

Regards,


* Do you have any access at all to this '20060618.xml' document?

Run this to check it:

<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>

<xsl:template match="/">
<xsl:copy-of select="documen t('20060618.xml ')"/>
</xsl:template>

</xsl:stylesheet>
- Do you seen any output? Can you acces the 'fuit' elements? Is it just
the attribute that's bothering you?
- If not, try:

<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>

<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>

- anything?
- is the name '20060618.xml' correct?
- Does it work when you include a full path name?
- maybe your xslt processor doesn't get permission to read he file? Maybe
it's a browser?

* Maybe the 20060618.xml document has a default namespace you didn't tell
us about?
- You'd have to include that namespace in the xslt

* What's <?xml-stylesheet type="text/xsl"
href="xsl_that_ tries_to_copy_b ut_does_not_wor k.xsl"?> doing in
XML_TO_COPY.XML ?
- If this is the source xml document with which the xslt does it magic,
why then use 'document()'?
- You speak of a merge, yet I only see one document.

Out of ideas:-)

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Gaudiam omnibus traderat W3C, nec vana fides
Jun 22 '06 #5

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

Similar topics

8
2033
by: AC | last post by:
I hope someone can tell me why this is not working. I have a form that dynamically creates the code below. This is for one product and there are about 10 to 50 products that are listed depending on what manufacturer the user selects. After "buying" a few products (4-8) they user gets the error message: 'QUANTITY.value' is null or not an object. Do you see a workaround/fix for this? I posted this on February 19, 2004 under the title...
4
14604
by: gimme_this_gimme_that | last post by:
Hi, I Oracle one can have : select to_char(a_id_seq.nextval,'0000') from dual Which fetches a sequence value and pads it with zeros on the left. When the sequence value is more than 4 digits '####' is returned.
5
3163
by: drdave | last post by:
Hi, I have 6 forms being generated using coldFusion, they are named special1, special2 special3 and so on.. in these forms I have a link to open a new window. I am trying to pickup the formname passed along to the new window.. the window opener function is: <SCRIPT LANGUAGE = "JavaScript">
2
2215
by: Ryan Liu | last post by:
Hi, What is the best practise to sove this problem: property with defalut value will not be called in auto-generated code ? for example
2
3389
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function checkInteger(&$value, $checks) { $err = ''; if (!is_numeric($value) || (floatval($value) != intval($value))) { $err .= 'Input must be an integer. ';
12
12138
by: Doogie | last post by:
How do I make a value the default value for a combo box in ASP 3.0? What I have below does NOT work, yet I've seen it in HTML file examples before (and works if I put it in a HTML file by itself, but not if I use it in a ASP 3.0 app. <select name="cboCompany" style="text-align:right; font-size:8pt"> <option value="08">08</option> <option value="09" selected="true">09</option> <option value="33">33</option>
1
1301
by: nudayasankar | last post by:
Hi all, I need to convert an XML using XSLT transformation. I want to call a template (with-param) in a loop. Intially I can call it with a default value. That template returns a value which should be passed in the next iteration. How can I achieve this? Example: Input: <parent> <commonChild><value>1000</value></commonChild> <child1><value1>100</value1></child1> <child1><value1>50</value1></child1> <child1><value1>75</value1></child1>
3
5545
by: whitey | last post by:
this code is producing the message BUT it is entering the data. What should i do? <?php if (!$_POST) { //haven't seen the form, so show it $display_block = " <form method=\"post\" action=\"".$_SERVER."\"> <p><strong>First/Last Names:</strong><br/> <input type=\"text\" name=\"f_name\" size=\"30\" maxlength=\"75\">
13
1670
by: Josip | last post by:
I'm trying to limit a value stored by object (either int or float): class Limited(object): def __init__(self, value, min, max): self.min, self.max = min, max self.n = value def set_n(self,value): if value < self.min: # boundary check self.n = self.min if value self.max:
6
4280
by: Ahmedhussain | last post by:
Hi there, I m doing work on a gridview and Im getting an error: A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span class='txtColo...") Im using an access database. and when ever I try to update this it doesnt work. <%@ Page Language="C#" MasterPageFile="Mysite.master" Title="Untitled Page" %> <script runat = "server"> protected void Page_Load(object sender,...
0
10315
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
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
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...
1
7494
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
6737
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.