473,569 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help inserting namespace

CB
I have a group of documents that previously had no schema, now I have
a schema, and I want to use XSLT to fixup the documents by inserting
the namespace reference.

In other words, my input document looks like

<SiteAdaptation File>
...
</SiteAdaptationF ile>

and I'm looking for output like

<SiteAdaptation File xmlns="http://www.sensis.com/AdaptSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.sensis.com/AdaptSchema IddAdapt.xsd">
...
</SiteAdaptationF ile>

Here is my xslt script. The foo attribute is just a dummy, and I
put it in because Xalan complains about the other attribute names,
and ignores them. i.e., i wanted to see something change.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et 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="/">
<xsl:apply-templates select="SiteAda ptationFile"/>
</xsl:template>

<xsl:template match="SiteAdap tationFile">
<xsl:element name="SiteAdapt ationFile">
<xsl:attribut e name="foo" >
<xsl:text>bar </xsl:text>
</xsl:attribute>
<xsl:attribut e name="xmlns" >
<xsl:text>htt p://www.sensis.com/AdaptSchema</xsl:text>
</xsl:attribute>
<xsl:attribut e name="xmlns:xsi " >
<xsl:text>htt p://www.w3.org/2001/XMLSchema-instance</xsl:text>
</xsl:attribute>
<xsl:attribut e name="xsi:schem aLocation" >
<xsl:text>http://www.sensis.com/AdaptSchema
IddAdapt.xsd</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

My actual output is

<SiteAdaptation File foo="bar">
...
</SiteAdaptationF ile>

I'm sure my question exposes my ignorance of XSLT, and I appreciate
any help, very much.
Jul 20 '05 #1
1 2271
"CB" <cb****@sensis. com> schrieb im Newsbeitrag
news:40******** *************** ***@posting.goo gle.com...
I have a group of documents that previously had no schema, now I have
a schema, and I want to use XSLT to fixup the documents by inserting
the namespace reference.

In other words, my input document looks like

<SiteAdaptation File>
...
</SiteAdaptationF ile>

and I'm looking for output like

<SiteAdaptation File xmlns="http://www.sensis.com/AdaptSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.sensis.com/AdaptSchema IddAdapt.xsd">
...
</SiteAdaptationF ile>

Here is my xslt script. The foo attribute is just a dummy, and I
put it in because Xalan complains about the other attribute names,
and ignores them. i.e., i wanted to see something change.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et 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="/">
<xsl:apply-templates select="SiteAda ptationFile"/>
</xsl:template>

<xsl:template match="SiteAdap tationFile">
<xsl:element name="SiteAdapt ationFile">
<xsl:attribut e name="foo" >
<xsl:text>bar </xsl:text>
</xsl:attribute>
<xsl:attribut e name="xmlns" >
<xsl:text>htt p://www.sensis.com/AdaptSchema</xsl:text>
</xsl:attribute>
<xsl:attribut e name="xmlns:xsi " >
<xsl:text>htt p://www.w3.org/2001/XMLSchema-instance</xsl:text>
</xsl:attribute>
<xsl:attribut e name="xsi:schem aLocation" >
<xsl:text>http://www.sensis.com/AdaptSchema
IddAdapt.xsd</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

My actual output is

<SiteAdaptation File foo="bar">
...
</SiteAdaptationF ile>

I'm sure my question exposes my ignorance of XSLT, and I appreciate
any help, very much.


XSLT doesn't treat namespace declarions as attributes.

Just do something like:

<xsl:template match="SiteAdap tationFile">
<SiteAdaptation File xmlns="http://www.sensis.com/AdaptSchema">
<xsl:apply-templates/>
</SiteAdaptionFil e>
</xsl:template>
Jul 20 '05 #2

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

Similar topics

3
1717
by: jwalton | last post by:
This is so silly I must be doing something wrong! I need to insert (using VB.NET) a new node in a DOM; node has a namespace. I first create, under programme, basic structure, starting thus: <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"...
10
11587
by: Ryan Graham | last post by:
I totally bombed this question in an interview so I'm posting my answer here for comments and suggestions... perhaps (god help me) I'm just not that bright, but this works and seems to be fairly efficent. The idea was simple, insert an integer into a list that has already been sorted. private int _list; .... public void Insert(int value)...
1
1982
by: Kevin | last post by:
Hello experts, I'm a newbee to ASP.NET. And I have been struggling solving this problem. But I can't do it. Can you please help me get over this wall? Below is the code and error message: <%@ Page Language="vb" AutoEventWireup="true" Codebehind="RegisterForm.aspx.vb" Inherits="WebApplication1.RegisterForm"%> <%@ import...
2
2561
by: altergothen | last post by:
Hi there I am a newbie to ASP.Net - Please Help! I am trying to insert the values of my variables into a database. If I try the following it works perfectly: string insertQuery = "INSERT into test(name,surname,email) VALUES('Bob', 'Sly', 'bobsly@yahoo.com')"; but instead of inputing the values directly, I want to insert them as...
5
3772
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
0
2993
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Where Peter is the value...
4
2217
by: orel | last post by:
<o_r_l_25@yahoo.frwrote, As the message says, to help the compiler with template parsing, I add 'typename' as you said, it now understands the expression, but but i have now those complier errors : src\core\objectfactory.cpp:41: instantiated from here src\include\objectfactory.h:125: error: no matching function for call to...
0
1583
by: R. Ian Lee | last post by:
I've built an XSLT file that transforms data to SpreadsheetML format. The XSLT uses a <xsl:call-template/to build each worksheet. For some reason, when I transform the file, it is inserting xmlns="" attributes into my <Worksheetelements which causes the worksheet not to work with Excel. I'm using the System.Xml.Xsl.XslTransform class to...
1
2617
by: madhuxml82 | last post by:
Dear Forum Members, I have generated an XML Schema and a Table of XMLType referencing the XML Schema. Now When I am Inserting the Data into the Table. I am getting the Error 0RA-30937: Error is Comming. I am pasting the Code which I have written. Appreciate any Help... begin dbms_xmlschema.registerSchema(...
0
7695
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...
0
7922
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. ...
0
8119
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...
1
7668
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...
0
6281
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...
1
5509
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...
0
5218
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.