Hi!
Is there any function that converts a string containing characters
that are invalid for use in an element name to a valid one?
Thanks,
Andreas 6 2721 ad****@cs.tu-berlin.de wrote:
Is there any function that converts a string containing characters
that are invalid for use in an element name to a valid one?
Which programming language/framework are you using? The Microsoft .NET
framework has
XmlConvert.Enco deName
<http://msdn2.microsoft .com/en-us/library/system.xml.xmlc onvert.encodena me.aspx>
--
Martin Honnen http://JavaScript.FAQTs.com/
On 26 Feb., 13:30, Martin Honnen <mahotr...@yaho o.dewrote:
adu...@cs.tu-berlin.de wrote:
Is there any function that converts a string containing characters
that are invalid for use in an element name to a valid one?
Which programming language/framework are you using? The Microsoft .NET
framework has
XmlConvert.Enco deName
<http://msdn2.microsoft .com/en-us/library/system.xml.xmlc onvert.encode.. .>
--
Martin Honnen http://JavaScript.FAQTs.com/
Aah yes, sorry I have not been precise. I am looking for a xml
function like translate() or replace(). ad****@cs.tu-berlin.de wrote:
>>Is there any function that converts a string containing characters that are invalid for use in an element name to a valid one?
Aah yes, sorry I have not been precise. I am looking for a xml
function like translate() or replace().
In that case, I believe the answer is... translate(), or implement your
own recursive string processing if single-character substitutions aren't
sufficient for you. There's nothing standardized for this purpose, since
it isn't something commonly done.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
On 26 Feb., 14:06, Joe Kesselman <keshlam-nos...@comcast. netwrote:
adu...@cs.tu-berlin.de wrote:
>Is there any function that converts a string containing characters that are invalid for use in an element name to a valid one?
Aah yes, sorry I have not been precise. I am looking for a xml
function like translate() or replace().
In that case, I believe the answer is... translate(), or implement your
own recursive string processing if single-character substitutions aren't
sufficient for you. There's nothing standardized for this purpose, since
it isn't something commonly done.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Okay, thank you anyway.
One more observation: There are a heck of a lot of characters that are
valid in element names (just about any alphanumeric in just about any
language, plus some punctuation), since XML's defined in terms of
Unicode. Simply checking whether all the characters in an element name
are legal is something of a pain; figuring out what to replace the
(many!) other Unicode characters with is going to be (ahem) interesting.
The simplest solution would probably be to invent some sort of escaping
syntax (and then, as usual with such things, also escape the
escape-introduction sequence so the conversion is reliably unique and
reversible).
Unless you control ALL names in the document, that does introduce the
risk that a name created by someone else will contain something that
looks like an escape sequence.
BUT... frankly, you really don't *WANT* element names being made up on
the fly, since they're what describes the structure of your document.
Consider putting your non-XML descriptor in _content_, eg an attribute
value, rather than an element name. Among other things, XML already has
the ability to escape characters in text content.
(You still won't be able to use every possible character, even after
escaping it, if you're working in XML 1.0. I believe XML 1.1 -- which is
rarely used -- expanded the legal character set, but you may not want to
make support for 1.1 a prereqisite. The alternative is to fall back to
inventing your own escaping mechanism, eg by doing a base-64 encoding
upon the UTF8 data.)
In other words: What problem are you really trying to solve, and is the
rather ugly kluge you proposed really necessary and/or sufficient?
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
On 27 Feb., 04:41, Joe Kesselman <keshlam-nos...@comcast. netwrote:
One more observation: There are a heck of a lot of characters that are
valid in element names (just about any alphanumeric in just about any
language, plus some punctuation), since XML's defined in terms of
Unicode. Simply checking whether all the characters in an element name
are legal is something of a pain; figuring out what to replace the
(many!) other Unicode characters with is going to be (ahem) interesting.
The simplest solution would probably be to invent some sort of escaping
syntax (and then, as usual with such things, also escape the
escape-introduction sequence so the conversion is reliably unique and
reversible).
Unless you control ALL names in the document, that does introduce the
risk that a name created by someone else will contain something that
looks like an escape sequence.
BUT... frankly, you really don't *WANT* element names being made up on
the fly, since they're what describes the structure of your document.
Consider putting your non-XML descriptor in _content_, eg an attribute
value, rather than an element name. Among other things, XML already has
the ability to escape characters in text content.
(You still won't be able to use every possible character, even after
escaping it, if you're working in XML 1.0. I believe XML 1.1 -- which is
rarely used -- expanded the legal character set, but you may not want to
make support for 1.1 a prereqisite. The alternative is to fall back to
inventing your own escaping mechanism, eg by doing a base-64 encoding
upon the UTF8 data.)
In other words: What problem are you really trying to solve, and is the
rather ugly kluge you proposed really necessary and/or sufficient?
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Hi!
Thank you for your extended thoughts on this. As you might have
guessed, I´m pretty new to XML. In my case a tool from a toolchain can
export results as a xml-file. Until now this feature has not been used
but now we want to use it and therefore import it to another tool. As
you can imagine the output is not compatible to what the second tool
can import so I'm currently writing a xsl transformation. In order to
do this, some element values will become element names in the output
xml. Meanwhile I have found the problem I was facing when I posted
this not to be illegal characters in regard to xml (except some
spaces), but the fact that the second tool doesn´t accept a whole
bunch of characters used in the source xml. Consequently it seems to
me that translate() is my choice. If you can advice otherwise, please
tell me!
Regards,
Andreas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Powell |
last post by:
<?php
class Grad {
var $dbFormExemptionArray = array();
function Grad ($id = '') {
/*----------------------------------------------------------------------------------------------------------------------
Do note that if you are generating arrays that will not have
|
by: Penn Markham |
last post by:
Hello all,
I am writing a script where I need to use the system() function to call
htpasswd. I can do this just fine on the command line...works great
(see attached file, test.php). When my webserver runs that part of the
script (see attached file, snippet.php), though, it doesn't go through.
I don't get an error message or anything...it just returns a "1"
(whereas it should return a "0") as far as I can tell. I have read the
PHP...
|
by: Susan Cranford |
last post by:
Please forgive, I have looked at so much info I can't figure out how to
put it together even though I know it must be fairly simple.
I have an array of input text boxes (txtDOBn) where n is created at
load. On the onchange event I want to calc the age and show in adjacent
input text boxes that are readonly and also arrays (an age calced for
each DOB entered). I was going to use the datediff function in vbscript
to do the calc.
Can...
|
by: mike |
last post by:
If I have a document like:
<script>
function mike_test()
{alert('hi');}
</script>
<iframe src="blank.html" id="my_iframe1">
</iframe>
and in blank.html I have:
|
by: I.M. !Knuth |
last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until
I started goofing around with this:
================================================================================
/* A function that returns a pointer-of-arrays to the calling function. */
#include <stdio.h>
int *pfunc(void);
| |
by: cryme |
last post by:
Im having a minor, simple problem. Basicly i have two different scripts they both work separately and together but just that both executes at the same time.
On my html page i have a form, one of the functions are that you can fill in the fields and when you press on a button you go to a new page, were all filled fields are shown.
Now i want to validate the form before i pass on the filled information to the "next page".
But right now...
|
by: Thiago Jorge |
last post by:
Hello Everyone!
I am trying to implement a form which some of the fields I have are
required.
In order to do that I am using the onBlur function, so when I either
click on a different field, or Tab out to the next field, it should
check if my last entry was not blank, and in case it was, it should
return to that field until the user enters a valid entry.
|
by: simon |
last post by:
hi,
I would like to separate my javascript completely from my xhtml. in the
end there should be only
<script type="text/javascript" src="javalib.js"></script>
in the head-tag to my javascript.
Because I want to use some ajax-requests and other javascript-functions
on my xhtml, I need to dynamically add event handlers to any possible
dom-elements. All solutions I found so fare are for specific, pre-known
|
by: bowlderster |
last post by:
Hello,all.
I want to get the array size in a function, and the array is an argument of the function.
I try the following code.
/***************************************
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |