473,770 Members | 4,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT: how to process whole document??

Hello

This is my problem:
It consider xml 2 xml conversion.
source document had unknown structure (xhtml),
xslt must process every node, attribute, text, comments etc. from source and
write in destination file.
During that process i must catch some nodes (e.g. <input> position of this
node in XML tree is unknown )and change the value attribute.
The destination xml file must be the exact copy of source file + changes on
value attribute on some nodes.

Where can i find some sample code that can process and write whole context
node by node, comment etc.

thanks for any help
Jul 20 '05 #1
1 3684


Bartek wrote:

It consider xml 2 xml conversion.
source document had unknown structure (xhtml),
xslt must process every node, attribute, text, comments etc. from source and
write in destination file.
During that process i must catch some nodes (e.g. <input> position of this
node in XML tree is unknown )and change the value attribute.
The destination xml file must be the exact copy of source file + changes on
value attribute on some nodes.

Where can i find some sample code that can process and write whole context
node by node, comment etc.


Start with the identity transformation as described here:
http://www.w3.org/TR/xslt#copying
then add templates for those elements you need to change, here is a
simple example, the XHTML is

<?xml version="1.0" encoding="UTF-8"?>
<html
xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<head>
<title>exampl e document to be transformed</title>
</head>
<body>
<form action="whateve r.php">
<fieldset>
<legend>Who is GOD?</legend>
<label>
Who is GOD?
<input type="text" name="GOD" value="???" />
</label>
<input type="submit" />
</fieldset>
</form>
</body>
</html>

the XSLT is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" encoding="UTF-8" />

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template
xmlns:xhtml="ht tp://www.w3.org/1999/xhtml"
match="xhtml:in put[@name = 'GOD']">
<xsl:copy>
<xsl:apply-templates select="@*[local-name() != 'value']" />
<xsl:attribut e name="value"><x sl:text>Kibo</xsl:text></xsl:attribute>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

the XHTML output is

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>exampl e document to be transformed</title>
</head>
<body>
<form action="whateve r.php">
<fieldset>
<legend>Who is GOD?</legend>
<label>
Who is GOD?
<input type="text" name="GOD" value="Kibo"/>
</label>
<input type="submit"/>
</fieldset>
</form>
</body>
</html>

so the value attribute has been changed.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

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

Similar topics

3
2126
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim is to process the contacts in a single-pass XSLT process. That is why the "document()" function is what I need. I call the "document()" XPath function from a "for-each" instruction.
4
5244
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } if (x) {
3
2197
by: Teksure | last post by:
Hi group, searching in the Internet I found two products for XML which incorporate a very robust debugger for XSL/XSLT, I would like you to see these products and then, give me your opinion about the development environment or recommend me some other that you know. XML IDE's - http://xslt-process.sourceforge.net - http://www.mentattech.com/themes/mentat/alchemist/index.html Regards,
4
1678
by: dar_imiro | last post by:
Hi, I'm trying to get rid of frames as menu holder in my html-page. I'd also like to separate the menu structure to xml and xslt. Also the actual content is divided to xml and its corresponding stylesheet. The idea ofcourse is to import the separate menu.xml to the content.xslt file so the menu markup wont clutter every content.xml page.
3
1911
by: msnews.microsoft.com | last post by:
Hi Does anybody know if XSLT can process several XML file at a time I have two xml document which stored in memory stream and wanna to combine it together under several rules. I am tring to use a XSLT file but donon how to process several xml at a time
3
2010
by: thomas.porschberg | last post by:
Hi, I want to read records from a database and export it in an arbitrary format. My idea was to feed a class with a String array fetched from the database and let this class fire SAX events as processor input. The basic class hierarchy is:
6
2656
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a "database frontend" type of intranet application. The existing table-display code consists of a mountain of very clever but extremely brittle spaghetti-javascript, which I'm planning to replace with XSLT transformations. At present I'm still...
12
11602
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I don't want to have to use some external program or script to parse the csv first if possible
3
9614
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the difference between two source documents and output node-sets which are "different" (changed or new) to new XML files using xsl:result-document To describe the problem I have provided some example data below along with my a portion of my current...
0
9592
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
10058
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...
0
8886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
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
6678
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
5313
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
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
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
3576
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.