473,385 Members | 1,693 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,385 software developers and data experts.

Tricky XSL xinclude question

Hello everybody,

i have these 2 xml files

------1.xml------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element>1</element>
<element>2</element>
</root>
------end--------

------a.xml------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<xi:include href="1.xml" xmlns:xi="http://www.w3.org/2003/XInclude"
/>
<element>A</element>
<element>B</element>
</root>
------end--------

and want to have these output:
A1
B2
and so on...

Are there possibilities the get this output with nested for each? I've
also played with position() in one single foreach, but i cant get
these output.

Please can someone help me? I have no problem to get the output AB12
or with an manually xpath index.

Thanks a lot

René
Jul 20 '05 #1
3 1593
ag***@gmx.de (rene) writes:
Hello everybody,

i have these 2 xml files

------1.xml------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element>1</element>
<element>2</element>
</root>
------end--------

------a.xml------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<xi:include href="1.xml" xmlns:xi="http://www.w3.org/2003/XInclude"
/>
<element>A</element>
<element>B</element>
</root>
------end--------

and want to have these output:
A1
B2
and so on...

Are there possibilities the get this output with nested for each? I've
also played with position() in one single foreach, but i cant get
these output.

Please can someone help me? I have no problem to get the output AB12
or with an manually xpath index.

Thanks a lot

René
Your problem description is rather under-specified..

Firstly does your XML parse implement xinclude so that your xxslt
stylesheet if given a.xml on input actually sees
<?xml version="1.0" encoding="UTF-8"?>
<root>
<root>
<element>1</element>
<element>2</element>
</root>
<element>A</element>
<element>B</element>
</root>

or does it not implement xinclude in which case inputing a.xml will
just give you a tree corresponding to teh form you posted and 1.xml
would have to be accessed separately using the document() function?

When you say and want to have these output:
A1
B2


do you mean elements with those names, or elements with that content, or
just plain text, or what?

David

Jul 20 '05 #2
Hi David,
<?xml version="1.0" encoding="UTF-8"?>
<root>
<root>
<element>1</element>
<element>2</element>
</root>
<element>A</element>
<element>B</element>
</root>


your xml tree is right i can access the /root/root/element/, which
give me the "1". The problem is, i will do something like that:

<xsl:for-each select="root/element">
<tr>
<td><xsl:value-of select="."/></td> <!-- give me A and so on -->

<!-- Thats the big question: access the 1 and so on in the same loop
<td><xsl:value-of select="../../element"/></td>
-->

</tr>
</xsl:for-each>

I've try /root/root[position()]/element in the for-each loop, but this
wont work.

Best regards

Rene
Jul 20 '05 #3
AHHH, I have it non sure if its a good way, but this gave me what i want

<xsl:for-each select="root/element">
<tr>
<td><xsl:value-of select="."/></td>
<xsl:variable name="i" select="position()"></xsl:variable>
<td><xsl:value-of select="/root/root/element[$i]"/></td>
<td><xsl:value-of select="document('1.xml')/root/element[$i]"/></td>
</tr>
</xsl:for-each>
</table>

your document question gives me also a helpful hint (thats looks better for me).

Rene
Jul 20 '05 #4

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

Similar topics

1
by: Erdem Guven | last post by:
I try to include some xml documents to another one and validate them. I get 'invalid content starting with element "xi:include".' error message at pointsample.xml line 6 from xml plugin of jedit...
1
by: CB | last post by:
I am using xerces 2.5.0 and xalan 2.6.0, and am following the xinclude instructions on the xerces faq at http://xml.apache.org/xerces2-j/faq-xinclude.html, and I am having no luck. I imagine I...
1
by: Larry | last post by:
Given the "includer" xml file: <?xml version="1.0"?> <test-includer xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:testns="http://www.w3.org/TR/REC-xml-names"...
9
by: Tjerk Wolterink | last post by:
I have an xml document that conforms to my xschema document. Now i wanted to use xinclude in my xml document. But when i want to validate the xml document to the xschema i get the following...
1
by: Sergey Numerov | last post by:
Of the numerous XML standards, the classes of System.XML support only XPath, XML Schema and DTD. If I want to exploit XLink, XInclude or XQuery, can .NET offer me anything? Are there third-party...
11
by: john fra | last post by:
Hi, I want to include a part of many XML files into an unique XML file with XInclude. Example! File1.xml, File2.xml, File3.xml... seems to that : <?xml version="1.0" encoding="UTF-8"?>
4
by: Tim Arnold | last post by:
I'm using ElementTree to access some xml configuration files, and using the module's xinclude capability. I've got lines like this in the parent xml file (which lives in the same directory as the...
7
by: shaun roe | last post by:
I should like to use xslt to produce a document like the following: <crate xmlns:xi="http://www.w3.org/2001/XInclude"> <rod id="0"> <slot>1</slot> <xi:include...
2
by: McSwell | last post by:
I have an XML file that looks something like this: ------------------------ <?xml ...?> <!DOCTYPE ...> <src:fragment id="foo" ...> <Ph:Itemsome stuff </Ph:Item> <Ph:Itemsome more stuff...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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.