473,609 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xsl:element question

2 New Member
I am trying to create XSLT to convert XML like this:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <sampledoc>
  3.     <asdf mytoken="name1234">
  4.         <qwer>value1234</qwer>
  5.     </asdf>
  6.     <asdf mytoken="name6789">
  7.         <qwer>value6789</qwer>
  8.     </asdf>
  9. </sampledoc>
  10.  
Into this:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <myroot>
  3.     <name1234>value1234</name1234>
  4.     <name6789>value6789</name6789>
  5. </myroot>
  6.  
This is what I thought would work using xsl:element tags:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3.     <xsl:output method="xml" encoding="UTF-8" indent="yes" />
  4.  
  5.     <xsl:template match="asdf">
  6.         <xsl.element name="{@mytoken}">
  7.             <xsl:value-of select="qwer"/>
  8.         </xsl.element>
  9.     </xsl:template>
  10.  
  11.     <xsl:template match="sampledoc">
  12.     <myroot>
  13.         <xsl:apply-templates/>
  14.     </myroot>
  15.     </xsl:template>
  16. </xsl:stylesheet>
  17.  
But the results I am getting is this (the xsl.element is carrying over instead of executing?):

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <myroot>
  3.     <xsl.element name="name1234">value1234</xsl.element>
  4.     <xsl.element name="name6789">value6789</xsl.element>
  5. </myroot>
  6.  
What am I missing to make this behave as I want? I haven't found any clues in my search of XSLT internet references and Q&A...

Thanks,
Bryan
May 4 '07 #1
3 1362
bklopfen
2 New Member
Well, all I had to do was post that to find the issue!!

If I had really typed xsl:element instead of xsl.element (colon instead of period) it would have worked the first time!

Thanks for being a forum where someone can ask questions like this!
Bryan
May 4 '07 #2
dorinbogdan
839 Recognized Expert Contributor
You're always welcome.

Glad to see you getting the answer.

God bless you,
Dorin.
May 7 '07 #3
Badrimahesh
4 New Member
hi do
i want help from pls help me, pls find the problem below

if i use like

select xmlelement (name ,xmlelemet(sub ,xmlattribute (sno)))
from emp;

out put

<name><sub sno = 123 </suba></name>

i want like

<name><sub sno = 123 /></name>
May 7 '07 #4

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

Similar topics

3
1707
by: Fran Cotton | last post by:
Hi, I'd greatly appreciate it if someone could cast light on my problem - I can't seem to find any reference to it anywhere. Consider the following XML: <paragraph> I am <emphasize>emphasized</emphasize> text inside a paragraph </paragraph> How do I go about transforming this into HTML like the following: <P>I am <EM>emphasized</EM> text inside a paragraph</P>
3
3207
by: Ray Tayek | last post by:
hi, trying to use an xslt to make an xslt. trying something like: <?xml version="1.0" encoding="UTF-8"?> <?xmlspysamplexml H:\java\projects\spy1\spy\inputDocumentMap.xml?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/inputDocumentMap"> <xsl:element name="xsl:template" match="/inputDocument">...
9
3278
by: Tom | last post by:
Hey all, I've been planning to get myself started with DocBook for quite some time now, so when I unexpectedly encountered a task for which DocBook might actually be very useful, I thought I'd no longer wait. Some Googling pointed me to several beginner tutorials, and I chose to get myself going with the guide at http://rzserv2.fhnon.de/%7Elg002556/docbuch/
1
7509
by: readytohelp | last post by:
I have the following XML <root> <Companies> <Name>Labs</Name> <display>Labs </display> <val>1</val> <Products> <val>1</val> <display>Maxa</display> <CompanyKey>1</CompanyKey>
1
1789
by: Wayne Lian via .NET 247 | last post by:
Hi all, Just wonder anyone have encountered this problem before?I tried using XMLSPY debugger and I can get the correct outputfor my XSLT transformation, however in .net, aftertransformation the attributes I put inside xsl:element tagcannot be generated. Part of the XML data: <?xml version="1.0" encoding="utf-8"?> <receipients> <receipient> ... <ServerUrl>http://win2003p2/</ServerUrl>...
1
2369
by: Filip Hendrickx | last post by:
Hi there. I want to generate elements, choosing the element name dynamically. So I tried to use attribute value templates: <xsl:element name="{$local-name($someNode)}"> <!-- Generate element content. --> </xsl:element> where $someNode is an XML tree.
0
1073
by: Patrick.O.Ige | last post by:
I have a xml file and i want to format it using XSL I needed to do a distinct which is ok on the first node "Code" But when it gets to the "programDescription" node it prints out values for both Code="PRG004" and PRG005 which is CrazyTraining 2 and Program6 I want CrazyTraining 2 for PRG004 and Program6 for PRG005 Any help? Thx
0
1262
by: Rote Rote | last post by:
I have an Xml file and XSL o format it below. I have tried to distinct the "ProgramCode" and the "programDescription" attributes but after that i still get repeatable data of CourseCode,CourseDescription etc ANy helps XML file ---------
4
1677
by: ina | last post by:
Hello all, I am newbie in xml and have a problem with this parse. I have this xml.file <Style> <Strategy>
0
8130
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
8076
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
8541
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
8222
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
8406
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
7002
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
6057
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
4085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2531
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.