473,795 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xmlns confusion

I'm trying to follow the recommendations for svg writing at
http://jwatt.org/svg/authoring/
and I am generating my svg with xslt. I had some problem with
namespaces, and although I think I solved it, I don't really understand
how.

My first try at writing svg introduced the svg with

<svg:svg xmlns:svg="http ://www.w3.org/2000/svg" width="600px"
height="400px" viewBox="-10 -10 620 420">

and all subsequent svg (e.g. rect, circle..) elements had svg: namespace
prefixes. In order to get no errors in my editor (oXygen), I had to also
declare the svg namespace in the stylesheet header :

<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:svg="http ://www.w3.org/2000/svg">

something about this seemed redundant so I started trimming..

eventually I have ended up with the stylesheet declaration as:
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns="http://www.w3.org/2000/svg">

and all my svg elements don't need prefixes any more.

Now my questions:

Is this a correct method, i.e. standards compliant, robust
What have I done? Have I changed the default namespace to svg? What's
the difference between this and using the 'base' attribute in the
stylesheet element?

I looked on the web but don't find this use of xmlns (with no namespace
element) documented.

thanks

shaun
Apr 18 '07 #1
2 2042
shaun roe wrote:
eventually I have ended up with the stylesheet declaration as:
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns="http://www.w3.org/2000/svg">

and all my svg elements don't need prefixes any more.

Now my questions:

Is this a correct method, i.e. standards compliant, robust
What have I done? Have I changed the default namespace to svg?
If you have the above default namespace declaration on the root element
of the stylesheet then all result elements that do not have a prefix in
their name will be in that default namespace, unless some other element
in the stylesheet clears the default namespace e.g. xmlns="" or
redefines the default namespace. So what you do is proper use and a
common use with XSLT to ensure that result elements belong to some
namespace, in this case the SVG namespace.
What's
the difference between this and using the 'base' attribute in the
stylesheet element?
What base attribute, the xml:base attribute? That is used to resolve
relative URLs but it does not define a namespace for elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 18 '07 #2
shaun roe wrote:
Is this a correct method, i.e. standards compliant, robust
What have I done? Have I changed the default namespace to svg?
Exactly. See reference below.
What's
the difference between this and using the 'base' attribute in the
stylesheet element?
Completely unrelated. Base sets a base URI that relative URI references
in the document should be interpreted relative to (rather than, as would
be normal, interpreting them relative to the location the document was
actually loaded from.) Since namespace names must always be absolute URI
references, base has no effect on namespaces.
I looked on the web but don't find this use of xmlns (with no namespace
element) documented.
In the namespaces spec,
http://www.w3.org/TR/2006/REC-xml-na...DefaultAttName

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Apr 18 '07 #3

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

Similar topics

1
4138
by: Chris Bedford | last post by:
Hi: this question has been driving me crazy. would be grateful for any help. I am writing a version of the identity transformation to filter some documents (they happen to be wsdl docs). My problem is that for just about every element in the output document all of the namespace defintions defined in my top
3
10043
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0" xmlns:ns1="abc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" media-type="text/xml" standalone="yes" version="1.0"/> <xsl:template match="/">
8
1904
by: Bob Smith | last post by:
hi all, I pretty new to xml, what does xmlns mean? like in: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:perljobs="http://jobs.perl.org/rss/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
1
5404
by: jorgen.wahlund | last post by:
Hi I have problems with transforming a xml document with Xalan and javax.xml.Transformer. Following xsl is used: <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xalan="http://xml.apache.org/xslt" xmlns:java="java"
4
3595
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C# code is, // Create an XSLT transform object XslTransform xslTransform = new XslTransform(); // Load the stylesheet
3
11195
by: dhurwitz | last post by:
I am trying to create an XML spreadsheet for use with Excel. I first saved a simple spreadsheet as an XML file, and now I am trying to recreate that file in code, using .NET 2.0. The beginning of the XML file should look like the following: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office"...
0
2797
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <product sku="10050-1653" xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <sku>10050-1653</sku> <name xml:lang="x-default">shop's Foie Gras</name> <online>1</online> ...
2
3793
by: CI | last post by:
I have the following XML file: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/ main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/ relationships"> <fileVersion appName="xl" lastEdited="4" lowestEdited="4" rupBuild="4505"/> <workbookPr defaultThemeVersion="124226"/> <bookViews>
1
4257
by: nwbabcock | last post by:
I'm using XmlSerializer to deserialize an xml into classes. The error I recieve is: Exception:There is an error in XML document (2, 2). Inner Exception: <applications xmlns='urn:xmlns:COMMONCENSUS:CommonFormat:IMSchema'> was not expected. I've read numerous threads on this but none seem to help with this particular issue. I've included the xml, and the Schema file below as well as the code. First post also, so I'm not sure how to add the...
0
9672
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
9519
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
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
10164
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
10001
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
9042
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
7538
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
6780
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.