473,386 Members | 1,827 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.

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_but_does_not_work.xsl "?>
<fruits date="20060621">
<fruit name="orange" />
</fruits>

COPY_RESULT_THAT_IS_INTENDED.XML
orange

XSL_THAT_TRIES_TO_COPY_BUT_DOES_NOT_WORK.XSL
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output
method="xml" indent="yes" /><xsl:template match="/">
<!-- ?!: this or something similar -->
<xsl:copy-of select="document('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 1385
On Wed, 21 Jun 2006 16:27:00 +0200, vo*******@spatiallink.org
<vo*******@spatiallink.org> wrote:
<xsl:template match="/">
<!-- ?!: this or something similar -->
<xsl:copy-of select="document('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('20060618.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="document('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="document('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="document('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*******@spatiallink.org
<vo*******@spatiallink.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="document('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:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>

<xsl:template match="/">
<xsl:copy-of select="document('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:stylesheet 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_but_does_not_work.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
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...
4
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...
5
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...
2
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
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...
12
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,...
1
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...
3
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...
13
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...
6
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...
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
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
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,...
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,...
0
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...

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.