First character a space in tag?

G

Gabe

What I want to do is to have a space as the first character in a tag:

<name>.John Smith</name>
and I want it to print as:
..John Smith

where "." = a space.

I need to do this because the software I am using requires the
following code for a multi-select drop down list.

<name>John Smith;Tom Jones;Harry James</name>

When the user does a multiselect, it looks like this:

John Smith;Tom Jones;Harry James

The user wants a space after each ";" so that it looks like this when
she does a multi-select:

John Smith; Tom Jones; Harry James

In order to get the first entry to line up with the subsequent
entries, I need to put a space before the first entry.

Is there any way in which to do this with XML?

Thanks ahead of time,

Gabe
 
J

Joseph J. Kesselman

Gabe said:
<name>.John Smith</name>
and I want it to print as:
.John Smith
where "." = a space.

You can do exactly that, exactly as you've shown it:
<name> John Smith</name>

But...
I need to do this because the software I am using requires the
following code for a multi-select drop down list.

Now you aren't talking about XML -- you're talking about the behavior of
the tool you're passing the XML to.

Assuming it's a browser, that's your problem; browsers are designed to
reformat text, and consider spaces in text to be only hints. You can try
replacing the space with a Required Blank character:
<name> John Smith</name>
Required Blank displays as a space but is not subject to the browser's
reformatting.

If the tool isn't a browser, you need to understand that tool's rules
for when spaces are and aren't preserved.

If you need additional help, it would be really useful to know exactly
what you're feeding this document to.
 
G

Gabe

You can do exactly that, exactly as you've shown it:
<name> John Smith</name>

But...


Now you aren't talking about XML -- you're talking about the behavior of
the tool you're passing the XML to.

Assuming it's a browser, that's your problem; browsers are designed to
reformat text, and consider spaces in text to be only hints. You can try
replacing the space with a Required Blank character:
<name> John Smith</name>
Required Blank displays as a space but is not subject to the browser's
reformatting.

If the tool isn't a browser, you need to understand that tool's rules
for when spaces are and aren't preserved.

If you need additional help, it would be really useful to know exactly
what you're feeding this document to.

Thanks Joseph for answering my question.

It is actually a forms editor where I first import a wmf form. Then I
do most of the xml coding with a WYSIWYG editor. When I save the file
with the leading space and reopen the file, the space is gone.

I had tried your solution before posting to this group. It works great
when I test it, but then when I save the file and reopen it, it does
this:

<name>&amp;#160;John Smith</name>

which is not what I want.

I will talk with the developer of the application about this.

Thanks for your help,

Gabe
 
J

Joseph J. Kesselman

It is actually a forms editor where I first import a wmf form. Then I
do most of the xml coding with a WYSIWYG editor. When I save the file
with the leading space and reopen the file, the space is gone.

Sounds like the editor is making unjustified assumptions. Figure out how
to reconfigure it. Or change tools.
<name>&amp;#160;John Smith</name>
which is not what I want.

Find out how that editor expects you to enter the required blank
character. Or change tools.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top