473,654 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL for recursive transformation

Hi,
I have a XHTML input file with custom tag which specifies html
fragments to include
For example:
<html>
....
<include frag1="frag1.ht ml" frag2="frag2.ht ml">
More html here
</include>
....html...
<include frag1="frag3.ht ml" ....>...

</html>
The include tag can be nested. The contents of an include tag would be
combined with the fragments [frag1.html and frag2.html] to produce the
output xml which would replace the currently processed include tag.
After that the whole output has to be checked for valid XML. And the
process is continued until there are no more include tags.

I was wondering about the best way to go about doing this. Is XSL
suitable? If so how?

Thanks
Indy

Feb 15 '06 #1
16 1845
Indy wrote:
I was wondering about the best way to go about doing this. Is XSL
suitable? If so how?


Given that XHTML is an XML language, the *right* way to do this would be
to use XInclude tags. Assuming your XHTML processor supports XInclude,
of course.

If it doesn't -- yes, you can implement XInclude, or similar
functionality, in XSLT if you want to. One such implementation can be
seen at http://www.dpawson.co.uk/xsl/sect2/include.html

(It's always worth checking Dave Pawson's XSLT FAQ website. He's done a
very good job of collecting many of the best answers from the XSLT
user's mailing list. Which, by the way, is also worth subscribing to if
you're looking for a deeper understanding of stylesheets.)
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 15 '06 #2
Joe Kesselman wrote:
Indy wrote:
I was wondering about the best way to go about doing this. Is XSL
suitable? If so how?

Given that XHTML is an XML language, the *right* way to do this would be
to use XInclude tags. Assuming your XHTML processor supports XInclude,
of course.


FWIW, mod_transform for Apache is an XSLT filter that supports XInclude
(based on libxml2/libxslt). So it's a solved problem on the Web.

However, XSLT is not a good solution to this, except for small
documents. Inclusion can be streamed, so it'll be hugely faster
and more scalable using a SAX-based parser. mod_publisher would
be a better choice.

--
Nick Kew
Feb 15 '06 #3
Indy wrote:
Hi,
I have a XHTML input file with custom tag which specifies html
fragments to include
For example:
<html>
...
<include frag1="frag1.ht ml" frag2="frag2.ht ml">
More html here
</include>
...html...
<include frag1="frag3.ht ml" ....>...

</html>
The include tag can be nested. The contents of an include tag would be
combined with the fragments [frag1.html and frag2.html] to produce the
output xml which would replace the currently processed include tag.
After that the whole output has to be checked for valid XML. And the
process is continued until there are no more include tags.

I was wondering about the best way to go about doing this.


Why not just use entity declarations?

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Feb 15 '06 #4
Peter Flynn wrote:
Why not just use entity declarations?


Parsed entities are pretty much dying as XML Schema replaces DTDs.
Schemas don't have any equivalent. XInclude/XLink were supposed to take
over that role.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 16 '06 #5
Hi,
Thanks for your comments, I tried using XInclude tags but came across
some problems.
The fragments that I'm trying to include are not valid XML themselves,
they could be for example be:
---sof---
<table><tr><td> This is a header</td></tr>
---eof---

and only when the fragments are assembled it forms a valid XML.

Do you think XInclude can still be used to achieve this?

Thanks again,
Indeera

Feb 16 '06 #6
In article <11************ *********@o13g2 000cwo.googlegr oups.com>,
Indy <in*****@gmail. com> wrote:
The fragments that I'm trying to include are not valid XML themselves, ....and only when the fragments are assembled it forms a valid XML. Do you think XInclude can still be used to achieve this?


No. XInclude operates at the level of the XML Infoset, not on
characters. You will need to use a non-XML tool to put them together.

-- Richard
Feb 16 '06 #7
Indy wrote:
The fragments that I'm trying to include are not valid XML themselves,


In which case XML-aware tools aren't going to handle them. Write
something text-based.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 16 '06 #8
.... or redesign the whole problem so you're working with XML structure
rather than text fragments.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 16 '06 #9
Indy wrote:
I have a XHTML input file with custom tag which specifies html
fragments to include


Other posters have suggested ways to include XML fragments in XML.

However I'd advise against this, because you're trying to embed HTML as
the fragment and HTML is _not_ XML. HTML needs to be processed with
text or SGML aware tools, not XML. What happens if you encounter a HTML
fragment that's not well-formed? What happens if you _want_ to use a
fragment that's not well forned?

RSS has addressed this same problem before now. Worth reading the
background.

Feb 16 '06 #10

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

Similar topics

0
2700
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron extension responsible for the xslt functions. The problem i have is that the obtained transformation is not the waited one. I try to proccess the same XML file with XSL file with a program called XMLspy and i obtained the desire and waited...
7
1990
by: bearophileHUGS | last post by:
(This is a repost from another python newsgroup). While using some nested data structures, I've seen that I'd like to have a function that tells me if a given data structure contains one or more cyclic references (a way to recognise a cycle in a graph is to do a depth-first search, marking vertices along the way. An already marked vertex means a cycle.) Do you know where I can find a function like this? To be more explicit about this...
0
1319
by: yurick | last post by:
Hello everybody, I have XML structure like this: <person name="adam"/> <person name="eve"/> <person name="cain"> <parent name="adam"/> <parent name="eve"/> </person>
0
1477
by: b0yce | last post by:
Hi all, I am trying to create a recursive loop transformation that remembers last position of inner loop so that it continues from that point instead of the point from where the recursion started. So if input XML is <SIMPLE> <1> <2>
7
2503
by: Rolf Kemper | last post by:
Dear All, somehow I remember that such or similar question was discussed already somewhere. But I can't find it anymore. I have a template calling itself. As long it goes deeper into the hierarchy (by the key) I can set the CurrentY parameter by itself + some constant correctly. Hence which each call the CurrentY gets bigger. But when the template reaches a leave and the caller is poped from
1
1361
by: Paul Guz | last post by:
I've discovered a quirk of .Net System.Xml.Xsl.XSLTransfrom that doesn't seem to exist in the MSXML2 transformation. When calling a recursive template for the first time, don't pass a parameter value using a variable with the same name as the parameter. This seems to cause the original value to remain constant in all recursive calls, even if you modify that value inside the template. To demonstrate: <xsl:template match="/">...
14
1895
by: BQ | last post by:
Due to a lack of resources, I have to translate the following recursive function in its iterative form. It's a kind of dichotomic search. void SearchSlaves(unsigned long start_uid, unsigned long end_uid) { char ret; //ping over a range of addresses (all slaves with uid in the range from start_uid to end_uid will reply) ret = PingSlave(start_uid,end_uid);
5
1842
by: monmonja | last post by:
Hi i'm new to xsl and i have been using smarty php templating but its just so hard to read codes in smarty/php/flash than xml/xsl/flash, i rather sacrifice speed then not being able to read code after 3 months. So my problem goes like this. I have an xml that like this <avatar> <avatarId>1</avatarId> <avatarName>MyNewAvatar</avatarName> <avatarFile> <fileName>MyNewAvatar.swf</fileName>
13
2079
by: jm.suresh | last post by:
Hi, I have a program which literately finds the object that overlapping a point. The horizontal and vertical search are called recursively from inside each other. Is this way of implementation fill the stack space with the local variables inside each call. If this is not good, is there a better way to implement? Or python itself will understand that the calls happen in the last line, so local variables need not be pushed into the stack?
41
3349
by: Harry | last post by:
Hi all, 1)I need your help to solve a problem. I have a function whose prototype is int reclen(char *) This function has to find the length of the string passed to it.But the conditions are that no local variable or global variable should be used.I have to use recursive functions.
0
8375
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
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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
8707
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
8482
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
8593
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
6161
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
4149
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
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.