473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

xsl:element question

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 1351
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 Expert 512MB
You're always welcome.

Glad to see you getting the answer.

God bless you,
Dorin.
May 7 '07 #3
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
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...
3
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...
9
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...
1
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
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...
1
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...
0
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...
0
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...
4
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.