473,732 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xlst transformation problem

13 New Member
Hi. everyone
I am new to xslt and Xforms technologies. I am trying to write a very simple xslt stylesheet to transform a very simple xml doc into Xforms doc. (Hello world example)
here are my xml doc and xslt stylesheet could plz tell me what wrong
with my stylesheet.
Remark: X-smiles is used as web browser and it returns an error message when the page is called.
the page is called as: http://localhost:8080/mydoc.xml
both xml do and xslt stylesheet in the same directory
many thanks in advance

here is xml doc:
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="styleshee t01.xslt"?>
<data>
<Name> Hello World </Name>
</data>

and here is XSLT
<?xml version='1.0'?> <xsl:styleshe et version="2.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xforms="h ttp://www.w3.org/2002/xforms/cr" xmlns:xmml="htt p://www.xmml.com" >
<xsl:output method="xhtml" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d" />

<xsl:template match="/">

<html>
<head>
<title>Title comes here </title>
<xforms:model >
<xforms:submiss ion action="" method="post" id="s"/>

<xforms:instanc e>
<xsl:apply-templates select="data" />
</xforms:instance >
</xforms:model >
</head>
<body>


<xforms:outpu t ref="data/name"/>
</body>
</html>
</xsl:template>

<xsl:template match="data/name">
<xsl:copy>
<xsl:copy-of select="data/name"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Nov 26 '07 #1
2 1671
jkmyoung
2,057 Recognized Expert Top Contributor
There are a couple of things that jump out immediately, but since I'm not sure what you're going for, it's hard to determine how to fix it.
1. xpaths are case-sensitive. name != Name
2. Context inside a template.
Once you're inside a template, the context changes, and you no longer have to include that part in your xpaths. The easiest way to fix your template would be to use:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="data/name">
  2.   <xsl:copy-of select="."/> <!-- copy the whole node -->
  3. </xsl:template>
  4.  
Have you tried using a XSLT program to give you a temporary result? Then you could see the intermediate html.

Suggested processors:
AltovaXML
Saxon. Requires Java or .NET
Nov 26 '07 #2
li72
13 New Member
Thanks for ur reply
as you can see i'm trying to write a (Hello world) example. considering the case-sensitive and Context inside a template. the outcome of this transformation is not what is expected it is the orginal xml doc (viewing source code in the browser ) whereas XForms doc is what I expect. this means the transformation does not work at all.
have got any clue.


There are a couple of things that jump out immediately, but since I'm not sure what you're going for, it's hard to determine how to fix it.
1. xpaths are case-sensitive. name != Name
2. Context inside a template.
Once you're inside a template, the context changes, and you no longer have to include that part in your xpaths. The easiest way to fix your template would be to use:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="data/name">
  2.   <xsl:copy-of select="."/> <!-- copy the whole node -->
  3. </xsl:template>
  4.  
Have you tried using a XSLT program to give you a temporary result? Then you could see the intermediate html.

Suggested processors:
AltovaXML
Saxon. Requires Java or .NET
Nov 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2133
by: Pascal Sartoretti | last post by:
Hello, I am looking for a formal definition of XSLT. Either a DTD or an XML Schema, whatever. Is there such a thing ? There is for instance one for XML Schema itself at http://www.w3.org/2001/XMLSchema.dtd . My problem is that I have a big set of XSLT files which may contain errors: for instance, use of XLST features that were only in the draft XSLT norm, but which Microsoft IE still supports. A DTD or XML Schema would greatly help me...
1
3062
by: Vital Lobachevsky | last post by:
Hi! I'm absolutely newbie with XSLT. Please, help me with this example. I have simple XML document like this: <skip /> <aaa> <link url="url1" /> <link url="url2" />
3
2628
by: Hai Nguyen | last post by:
I would like to know after transforming my datatables which store in dataset into XML form. Now I want to save it into a file and also create a XLST file to read it. How can I do that? Would you give me any advice or link to further my understandings. Thanks for any clues
3
1472
by: Hai Nguyen | last post by:
Sorry I don't have code yet. I'm asking for solutions which can help me solve the problem. This is the first time I have to cope this situation, hence I'm clueless how to start. I would like to ask for some ideas then I can start from scratch. Let's say: I have a dataset which has a table Customers (which retrieves from an Access Database) 1/ I convert it into XML format, it should look like this <Customer> <Name>...</Name>
1
1969
by: dave_kajinsky | last post by:
Hello all, I would like to do something with xlst, perhaps I can get help from this group? Here it goes: I've got 2 files: an ascii file and a file that identifies tokens in the ascii file. For example the ascii file could be:
0
8946
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
8774
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
9447
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...
1
9235
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
8186
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...
0
6031
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
4550
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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

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.