473,769 Members | 6,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create tag names via XSL

I have the following XML:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<ORDERS>
<ORDER>
<ORDER_ID>123 </ORDER_ID>
<X>a</X>
<X>e</X>
<X>f</X>
</ORDER>
<ORDER>
<ORDER_ID>124 </ORDER_ID>
<X>a</X>
<X>b</X>
<X>c</X>
</ORDER>
</ORDERS>

Is it possible to create the following XML document via XSL?

<?xml version="1.0" encoding="ISO-8859-1" ?>
<ORDERS>
<ORDER>
<ORDER_ID>123 </ORDER_ID>
<X1>a</X1>
<X2>e</X2>
<X3>f</X3>
</ORDER>
<ORDER>
<ORDER_ID>124 </ORDER_ID>
<X1>a</X1>
<X2>b</X2>
<X3>c</X3>
</ORDER>
</ORDERS>

Any ideas?

Thanx in advance,

Chris

Jul 20 '05 #1
4 1277
Additon: I know that there will bee a maximum of 32 x-entries in the
source document, the exact amount can vary, so there must be a
dynamically solution.

Chris

Jul 20 '05 #2
Chris wrote:
Is it possible to create the following XML document via XSL?


xsl:copy-of can do this for you:

<ORDERS>
<xsl:copy-of select="descend ant::*" />
</ORDERS>

Or didn't you mean to get an exact copy of the document?
JW

Jul 20 '05 #3
Janwillem Borleffs wrote:
Or didn't you mean to get an exact copy of the document?


No, the X elements were changed to X1, X2, X3, etc.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Jul 20 '05 #4


Chris wrote:
I have the following XML:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<ORDERS>
<ORDER>
<ORDER_ID>123 </ORDER_ID>
<X>a</X>
<X>e</X>
<X>f</X>
</ORDER>
<ORDER>
<ORDER_ID>124 </ORDER_ID>
<X>a</X>
<X>b</X>
<X>c</X>
</ORDER>
</ORDERS>

Is it possible to create the following XML document via XSL?

<?xml version="1.0" encoding="ISO-8859-1" ?>
<ORDERS>
<ORDER>
<ORDER_ID>123 </ORDER_ID>
<X1>a</X1>
<X2>e</X2>
<X3>f</X3>
</ORDER>
<ORDER>
<ORDER_ID>124 </ORDER_ID>
<X1>a</X1>
<X2>b</X2>
<X3>c</X3>
</ORDER>
</ORDERS>


Yes, one way to do it 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="ISO-8859-1" />

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

<xsl:template match="X">
<xsl:element name="X{count(p receding-sibling::X) + 1}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>

</xsl:stylesheet>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #5

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

Similar topics

7
8869
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
24
3123
by: flkeyman | last post by:
Work in legal office. Trying to create solid designed database structure. This is list of tables w/fields and primary keys. Any comments/advice greatly appreciated. tbl-Defendants CaseNumber (primary key) FirstName MiddleName LastName
3
2850
by: MLH | last post by:
I was running the following code while logged in as a user belonging only to the Users group. Set usrNew = .CreateUser(Me!UserID) 'The user ID is in a control on the form usrNew.PID = "AAA123456789" usrNew.Password = "password" .Users.Append usrNew
27
3793
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB updates the same data in all other four tables in the right places. I know it would be possible by using the ForeignKeyConstraint object. I have created the tables using the DataSet Visual Tool and I know it doesn't create any ForeignKeyConstraint obj....
8
3481
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 , etc. I want to go to the first row, do a WHERE statement, return the
4
12441
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
1
4532
by: clir | last post by:
Hi, I'm trying to create views on all my existing tables and for that I'd like to create a script or so. I don't want to specify the '*' for the columns in the create view statement. I prefer to specify the column names. I have the column names int sys.columns table but Do not know how to handle them to have a statement like that: CREATE VIEW myVIEW
3
1911
by: DKelley | last post by:
I'm receiving a "severe" error that I can't seem to trap and evaluate in SQL Server 2000 (and no, I can't switch to 2005, this is on our customers' machines). And I've not been able to find info on this specific problem. This is essentially the statement I'd like to catch and gracefully quit if it occurs: CREATE UNIQUE NONCLUSTERED INDEX UQ_First_Key_SecondField_ThirdField ON . ( Prime_Key, SecondField, ThirdField ) ON SET @ErrorNumber...
0
1729
by: kurtf | last post by:
Hope somebody could help me with the creation of a table in sqlite3 from python. I am developing an application that allows a user to import a data file and insert the data into a sqlite3 database. I want the names of the fields to be derived from the first row of the file. I have been trying to perform this with code like: # CODE BEGIN import sqlite3
0
9423
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
10214
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
10048
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
9996
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
9865
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
8872
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
7410
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...
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.