473,776 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT: Confusion over adding attributes with xml:element and xml:attribute

Hi there.

I am working with lom metadata and I am a little confused with how to
form the following xml element:

<lom xmlns="http://www.imsglobal.o rg/xsd/imsmd_v1p2"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.imsglobal.o rg/xsd/imsmd_v1p2
imsmd_v1p2p2.xs d"/>

I have the following so far:

<xsl:element name="lom">
<xsl:attribut e namespace="xmln s"
name="xsi">http ://www.w3.org/2001/XMLSchema-instance</xsl:attribute>

<xsl:apply-templates/>
</xsl:element>

but it creates some very strange results. Does anyone know how I could go
about forming this tag? I know I could do it withou xsl:element, but I'd
like to do everything by the books.

Any help would be greatly appretiated.

Cheers!

...jordan willms
Jul 20 '05 #1
2 3405
jp******@sfu.ca (Jordan Willms) writes:
Hi there.

I am working with lom metadata and I am a little confused with how to
form the following xml element:

<lom xmlns="http://www.imsglobal.o rg/xsd/imsmd_v1p2"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.imsglobal.o rg/xsd/imsmd_v1p2
imsmd_v1p2p2.xs d"/>

I have the following so far:

<xsl:element name="lom">
<xsl:attribut e namespace="xmln s"
name="xsi">http ://www.w3.org/2001/XMLSchema-instance</xsl:attribute>

<xsl:apply-templates/>
</xsl:element>

but it creates some very strange results.
actually you shouldn't get a result at all, it is a syntax error to try
to generate an attribute with name xmlns. XML namespace declarations
are not attributes as far as Xpath is concerned, they can't be generated
with xsl:attribute, they don't show up if you select @*.

Just generate the attribute that you need (xsi:schemaLoca tion) any
needed xml namespace declarations will be generated automatically.
Does anyone know how I could go
about forming this tag? I know I could do it withou xsl:element, but I'd
like to do everything by the books.
Not sure what you mean by "by the books" I'd expect most xslt books to
advise thatyou don't need to use xsl:attribute or xsl:element unless you
need to generate the element or attribute names dynamically.
The main idea of xslt is that the templates should look like a
"template" for part of your result document, so it would b emore natural
to just use the form you give at the top rather than using xsl:element.

Any help would be greatly appretiated.

Cheers!

..jordan willms


David
Jul 20 '05 #2
In article <bb************ **************@ posting.google. com>,
Jordan Willms <jp******@sfu.c a> wrote:
I know I could do it withou xsl:element, but I'd
like to do everything by the books.


By what book? There is no good reason to use xsl:element when you
could use a literal result element. You're just making life
unnecessarily complicated.

-- Richard
Jul 20 '05 #3

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

Similar topics

1
6589
by: qa4ever | last post by:
How long in number of characters can a XML attribute be maximum? E.g. <mystring>how many characters maximum can be here</mystring> If you answer something like; it can be as long as UTF-8 . Then I ask, how long can UTF-8 be in charaters? qa4ever
3
1466
by: schaf | last post by:
Hi ! I have a little question. With my XSL File I add additional XML-Tags to an existing XML-File. But I would like to use a xsl:variable for inserting a value into an additional xml-attribute. <xsl:template match="Header"> <xsl:copy > <xsl:apply-templates select="SubHeader"/> <xsl:variable name="ProjectName" select="SubHeader/@name"/> <SubDir name=$ProjectName>
0
957
by: kosaraju.puneeth | last post by:
I am using Xml schema based validation for XML files. * I have attributes of Required,optional and anyAttribute type. Now can i validate my XML file in such a way that under a particular element i find only 2 attributes present(including anyAttribute type)? * <a> <b/> <!--Optional element/attribute--> <c/> <!--Optional element/attribute--> <d/> <!--Optional element/attribute-->
4
2524
by: smita | last post by:
Hi, I have an xml file as below <root> <table id =1> <user>abc</user> <age>25</age> </table> <table id = 2> <user>xyz</user>
4
2190
by: John Lau | last post by:
Hello, In Asp, you can render a server side variable inside the quotes in an html element attribute. For example: <link rel="stylesheet" href="<%=SomeVariableName%>" type="text/css"> I'm trying to do something similar in Asp.Net: <link rel="stylesheet" href="<SomePlaceholderControl runat=server>"
2
8713
by: alexs | last post by:
Chaps, I'm starting to play with db2 V9.1 and am writing a stored procedure to manage accounting records from oiur RADIUS server. I've got an XML aware table with an auto increment primary key, a few sql columns and an XML column. For every XML object I'm inserting, i'd lke to have an ID attribute that has the same value as the SQL primary key that'll be created upon executing the insert.
1
1958
by: emma_middlebrook | last post by:
Hi Goal: trying to validate a string to see if it can be a valid XML attribute name and, if not, replace any of the invalid characters with an underscore (to fix it up). Is there anything in the dot net framework to help with this? If not, I'm guessing writing a regular expression is the way forward. The specification is 2.3 Common Syntactic Constructs at
1
1511
by: Ravi | last post by:
Hi, I want to use end line character('\n') in the XML Attribute like <message confirm=" This will kill your process . \n Are you sure to proceeed? "/> But in java xml processor, it is considered as two characters "\" and "n". I used the xml encoding type as "ISO-8859-1". Pls any one help me on it ?
0
2276
by: sowmyavsh | last post by:
Below is my asp.net code which should fetch the correct answer from the xml document. how can i store the xml attribute (i.e to an object or string)? it is throwing an error object reference not set to the instance of the object could any one help me <?xml version="1.0" encoding="utf-8" ?> <quiz> <mchoice> <question>Which of the following characteristics distinguishes man from the other animals </question> <answer>Ability to stand erect...
2
3728
by: sqad | last post by:
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib"> ....something </JiraJelly> Anyone know how to create this xml tag using the xsl:element? Having a problem with the "xmlns:jira" namespace part...parser hates that. Thanks, sqad
0
9628
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
10120
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
10061
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
8952
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
5367
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...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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.