Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to value-of in copy-of in document to merge ?

Reply
Thread Tools

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

 
 
volunteer@spatiallink.org
Guest
Posts: n/a
 
      06-21-2006
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform"><xslutput
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.

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      06-21-2006
On Wed, 21 Jun 2006 16:27:00 +0200, http://www.velocityreviews.com/forums/(E-Mail Removed)
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
volunteer@spatiallink.org
Guest
Posts: n/a
 
      06-21-2006
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,

 
Reply With Quote
 
volunteer@spatiallink.org
Guest
Posts: n/a
 
      06-21-2006
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,

 
Reply With Quote
 
Joris Gillis
Guest
Posts: n/a
 
      06-22-2006
On Thu, 22 Jun 2006 00:23:02 +0200, (E-Mail Removed)
<(E-Mail Removed)> 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 xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput 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 xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Control Document Generation with New Mail Merge Cleanup Options sherazam Java 0 01-09-2012 07:12 PM
How to value-of in copy-of document to merge ? volunteer@spatiallink.org XML 1 06-21-2006 11:01 PM
Help,I can't merge word document in the server lee_j ASP General 6 11-27-2003 05:31 AM
Xalan document() function finding wrong document root Steve Carrow Java 0 07-28-2003 02:28 AM



Advertisments