Solved

Transforming XML with XSL to get HTML

Posted on 2014-03-18
7
286 Views
Last Modified: 2014-05-23
Hi experts,

I’m using XSL templates to transform an XML file to get an HTML.

I have some issues using the same name for different nodes (server side)

EG. “last-name”

XML File

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <path1>
     <last-name>
     </last-name>
   </path1>
   <path2>
     <last-name>
     </last-name>
   </path2>
</root>


XSL FILE

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>title</title>
…….

<xsl:for-each select="//path1">
      
<input type="text" size="25" name="last-name" id="last-name" value="{last-name}" maxlength="{last-name/@length}" />

</xsl:for-each>
……

<xsl:for-each select="//path2">
      
<input type="text" size="25" name="last-name" id="last-name" value="{last-name}" maxlength="{last-name/@length}" />

</xsl:for-each>

Should I  change the path of the templates?
which is the appropriate way to name the input fields?

Thanks for your help!

Rgs,
0
Comment
Question by:alcani
7 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 39938562
The question is not really very clear, at least to me :)

Can you explain a bit further on exactly what you are asking us to help you with. Also, it isn't clear on what the logical data model is that you are representing with that XML, ie. what do path1 and path2 relate to?

Providing the code and the input XML is good, but can you provide some more words explaining in detail what you are trying to do, the issues that you are facing, etc?
0
 

Author Comment

by:alcani
ID: 39938720
Ok, I’m sorry. I’ll try to explain it.

In fact we are processing xml files using xsl stylesheets and output is an html form.

Server side is a product called xcentrisity http://www.microfocus.com/assets/xcentrisity_tcm6-3589.pdf

Attached XSL and XML files

The problem is that server side is not identifying the node because I have many nodes with the same name

Eg. “apellido-paterno”

I think I have to express the attribute “name” from the input field using an xpath expression or some thing like that.

I hope this will help.

Regards,
P7AVIUIF01.xsl
ARCHIVO01.xml
0
 
LVL 16

Accepted Solution

by:
Wasim Akram Shaik earned 500 total points
ID: 40001014
I think Using namespaces for the elements would help..

they  would help the processor in distinguishing them

check this link on how to use namespace

http://www.w3schools.com/xml/xml_namespaces.asp
0
 
LVL 58

Expert Comment

by:Gary
ID: 40079618
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
 
LVL 16

Expert Comment

by:Wasim Akram Shaik
ID: 40079619
Using namespaces for elements would help in resolving the issue what author has pointed out, so please treat comment http:#a40001014 as an answer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now