473,763 Members | 6,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transform name elements of a xml in another name

Gi
Hi,

Can anyone tell me you can I transform this kind of XML:
<Cont ID='faqs'>
<Conts ID=''>
<Elements>
<Data></Data>
<Pergunta></Pergunta>
<Resposta></Resposta>
</Elements>
</Conts>
</Cont>

in this kind:
<element xmlns="" name="Mod">
<complexType>
<sequence>
<element name="Autor"/>
<element name="Data"/>
<element name="Pergunta"/>
<element name="Resposta"/>
</sequence>
</complexType>
</element>

Another thing: A few tips on good xsl pages on the internet, like
tutorials and stuff like that.
thanks
Gi

Apr 19 '06 #1
1 1392


Gi wrote:
Can anyone tell me you can I transform this kind of XML:
<Cont ID='faqs'>
<Conts ID=''>
<Elements>
<Data></Data>
<Pergunta></Pergunta>
<Resposta></Resposta>
</Elements>
</Conts>
</Cont>

in this kind:
<element xmlns="" name="Mod">
<complexType>
<sequence>
<element name="Autor"/>
<element name="Data"/>
<element name="Pergunta"/>
<element name="Resposta"/>
</sequence>
</complexType>
</element>
It is not quite clear where the element name="Autor" comes from and
where some of the attribute values come from, besides that this example
stylesheet

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" indent="yes" />

<xsl:template match="Cont">
<element name="Mod">
<xsl:apply-templates select="*" />
</element>
</xsl:template>

<xsl:template match="Conts">
<complexType>
<xsl:apply-templates select="Element s" />
</complexType>
</xsl:template>

<xsl:template match="Elements ">
<sequence>
<xsl:apply-templates select="*" mode="element-definition"/>
</sequence>
</xsl:template>

<xsl:template match="*" mode="element-definition">
<element name="{local-name()}" />
</xsl:template>

</xsl:stylesheet>

gives the result

<element name="Mod">
<complexType>
<sequence>
<element name="Data" />
<element name="Pergunta" />
<element name="Resposta" />
</sequence>
</complexType>
</element>

Another thing: A few tips on good xsl pages on the internet, like
tutorials and stuff like that.


Definitely
<http://www.dpawson.co. uk/xsl/sect2/sect21.html>
is a place to look for solutions/answers.

Tutorial like sections are here
<http://www.jenitenniso n.com/xslt/index.html>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 19 '06 #2

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

Similar topics

6
4873
by: Gary Huntress | last post by:
Hi, I'm having trouble with an xslt transform. I'm trying to transform a vector into an array of width N. For example here is my vector: <data> <x id="1">1.2</x> <x id="2">.2</x> <x id="3">.87</x> <x id="4">.333</x>
0
1267
by: Terry Brown | last post by:
I have an xml file: <?xml version="1.0" encoding="utf-8" ?> <G2Registers xmlns="http://tempuri.org/registers.xsd"> <register> <name>Version Register</name> <address>"00000000"</address> <verilogname>"PPC_Version"</verilogname> <bitfield>
1
1507
by: adi | last post by:
hello all, seems like a simple issue, but having tried several approaches with no success I am posting this question, I have a XML in one format, I want to now convert into another XML format using XSLT. FirstType.XML: (In this XML the States sub elements appear within USA element) ------------------------------------------------
3
2755
by: R. P. | last post by:
Subject: XSLT to transform a flat XML file into a structured text file I have an XML file that lists the PDF file segment names and titles of a larger document and looks something like this: <DOCUMENT> ...... ...... some lead elements ...... <SEGMENT_LIST>
12
2919
by: das | last post by:
Hello all, I am using .NET XSLT to transform an XML into another XML file. All this is fine with small files, but when tested with big files (30MB) it is taking between 1hr-2hrs to just transform the file. Here is the code snippet: XPathDocument xdoc = new XPathDocument(fs); XPathNavigator nav = xdoc.CreateNavigator(); xslt.Transform(nav, null, strWriter, null);
2
1518
by: Diego Martins | last post by:
Hi! Often, I have some situations when I have to convert a vector of 10 elements to a vector of 30 elements or vice-versa. (the ratio is 1-3) I want to use the std::transform do to these tasks, but I end up using std::for_each Is a special/custom iterator the only way to do that with std::transform?
3
1994
by: @CL | last post by:
Hi,all I was confused with xml transform. I had a xml file like: <Details> <names> <name/> <name/> ......or more <name/> </names>
3
2002
by: messagewalker | last post by:
Hello All, I am stuck with a problem. I have an xml file as follows <parent> <publisher> <name>somename</name> <book1>data1</book1> <book2>data2</book2> <book3>data3</book3>
3
7346
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
0
9563
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
9386
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,...
1
9937
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
9822
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...
0
8821
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
6642
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
5270
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...
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.