473,654 Members | 3,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

formatting text in an xml datastore

I am using an xml file to store data. I can get the data out now, but I
have a problem with any field that needs text formatting such as bold,
carriage return/linefeed, htmls tags.

Can some one point me to a good tutorial that will help me learn this,
or give me an example?

Thanks,
Irvin.

<product>
<title>My product Title</title>
<prod_date>20.M ay.1999</prod_date>
<desc>
Paragraph one.
Paragraph two.
</desc>
</product>

Jul 20 '05 #1
8 2671
Irvin wrote:
I am using an xml file to store data. I can get the data out now, but I
have a problem with any field that needs text formatting such as bold,
carriage return/linefeed, htmls tags.

Can some one point me to a good tutorial that will help me learn this,
or give me an example?
Use XSLT.
<product>
<title>My product Title</title>
<prod_date>20.M ay.1999</prod_date>
<desc>
Paragraph one.
This is going to be a problem. You really need to have something better
than a newline in there to signal paragraphs.
Paragraph two.
</desc>
</product>


<desc>
<para>Paragra ph one.</para>
<para>Paragra ph two.</para>
</desc>

Don't be tempted to pretend that linebreaks are a substitute for paragraph
start and end. They're not.

e.g.:

<xsl:template match="title">
<h1>
<xsl:apply-templates/>
</h1>
</xsl:template>

<xsl:template match="prod_dat e">
<h2>
<!-- get rid of the periods in the date -->
<xsl:value-of select="transla te(.,'.',' ')"/>
</h2>
</xsl:template>

[and much more].

///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
Jul 20 '05 #2
Peter,
Thanks for your quick reply. I am completly new to xml! But it looks
like it could be fun to work with.

Anyways, I actually found a way to do what I wanted!
<desc><![CDATA[<p"Paragraph one".</p><p>It's paragraph two.</p>]]
</desc>

But now I have a new problem!

Only part of the text shows up! Is there a limit to the number of
characters that a Node(?) can return? It cuts off mid sentence, no
special charaters nearby. You can take a look here:
http://www.ivan-isabel.com/test/test.xml <- XML datastore
http://www.ivan-isabel.com/test/articles.php <- PHP/XML version (cut
off text)
http://www.ivan-isabel.com/articles.html <- Static version (full text)
Thanks again for your help.

Irvin.

Jul 20 '05 #3
Hi,
Thanks for your quick reply. I am completly new to xml! But it looks
like it could be fun to work with.

Anyways, I actually found a way to do what I wanted!
<desc><![CDATA[<p"Paragraph one".</p><p>It's paragraph two.</p>]]
</desc>

But now I have a new problem!

Only part of the text shows up! Is there a limit to the number of
characters that a Node(?) can return? No, there are no limitations. It cuts off mid sentence, no
special charaters nearby. You can take a look here:
http://www.ivan-isabel.com/test/test.xml <- XML datastore
http://www.ivan-isabel.com/test/articles.php <- PHP/XML version (cut
off text)
http://www.ivan-isabel.com/articles.html <- Static version (full text)


I don't see any mid-sentence cuts on those pages (maybe you repaired it already), but when I look at the source code of the PHP version, I see this:

<para><p><![CDATA[...is a key to entering into the Father’s kingdom, and
since we know that He wants us to enter in, we are all capable
of opening the door to it.</p></para>
<para><![CDATA[<p class="style">W hat is prophecy? It is simply hearing the
Father speaking and repeating what He says, perceiving the
Father’s heart for someone and then sharing it with ...

First of all, it's useless to put markup data in a CDATA section. In the genrated HTML as well as in the source XML.
Secondly, the CDATA sections, if used, must be closed with ']]>'
Finally, the 'para' element isn't defined in HTML4.0
Maybe these errors are causing the mid-sentece cuts on your browser.

btw, you could consider to use XHTML, CSS and table-free design:-)

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #4
Joris,
Thanks for your reply. I have added comments to your posting.
I don't see any mid-sentence cuts on those pages (maybe you repaired it already ...

No. I still have that issue. I have tried in IE 6.0 and Mozilla
FireFox.
First of all, it's useless to put markup data in a CDATA section. In the genrated HTML as well as in the source XML.

Is there a better way to do it? The user needs to be able to add style
his text with bold, italic, and stylesheet classes.
Secondly, the CDATA sections, if used, must be closed with ']]>'
Ya. I caught that after I posted.
Finally, the 'para' element isn't defined in HTML4.0
I already dropped that.
btw, you could consider to use XHTML, CSS and table-free design:-)
I have never looked at XHTML before.
Ceterum censeo XML omnibus esse utendum

Translated, this means?

Thnaks again!
Irvin.

Jul 20 '05 #5
>> I don't see any mid-sentence cuts on those pages (maybe you repaired
it already ...

No. I still have that issue. I have tried in IE 6.0 and Mozilla
FireFox.
That's weird: in my Opera browser, I cannot see any problem, but when I set my preferences to 'indentify as MSIE 6.0' , the line is indeed broken. It seems the algorithm in the PHP that checks the browser type is broken. I cannot help you with that; I don't know any PHP.
First of all, it's useless to put markup data in a CDATA section. In

the genrated HTML as well as in the source XML.

Is there a better way to do it? The user needs to be able to add style
his text with bold, italic, and stylesheet classes.

Well, CDATA sections are, as the word says, meant to be encapsulate Character Data i.d. characters _without_ markup. So it doesn't make sense to put 'tags' in CDATA, because they will be parsed as &lt; and &gt; .I'd just omit the CDATA declaration (certainly in the HTML generated):
<desc><p"Paragr aph one".</p><p>It's paragraph two.</p>
</desc>
Secondly, the CDATA sections, if used, must be closed with ']]>'


Ya. I caught that after I posted.
Finally, the 'para' element isn't defined in HTML4.0


I already dropped that.
btw, you could consider to use XHTML, CSS and table-free design:-)


I have never looked at XHTML before.

roughly spoken, XHTML is HTML written with XML strictness. So you can perform XSLT on a XHTML page, it's more versatile.
Ceterum censeo XML omnibus esse utendum

Translated, this means?

:-) Furthermore, I am of the opinion that XML must be used by everyone/for everything.

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #6
Thanks for your help on this.
With regards to CDATA, the <p> tags seem to be presented well in the
browser. It doesn't appear to break anything. If I take them out I
loose my paragraph style and end up with one long paragraph.
I will post this whole issue with a PHP/XML forum and see what they
say.

Irvin.

Jul 20 '05 #7
Irvin wrote:
Peter,
Thanks for your quick reply. I am completly new to xml! But it looks
like it could be fun to work with.

Anyways, I actually found a way to do what I wanted!
<desc><![CDATA[<p"Paragraph one".</p><p>It's paragraph two.</p>]]
</desc>
Yes, but don't be misled. The text inside a CDATA Marked Section is
*not* XML or HTML, as far as the processor is concerned, it's just a
bunch of letters and signs with no meaning, so it cannot be accessed
or manipulated as XML or HTML, only output as a string, which by luck
means something in the target environment.

It may not be important in a small test like this, but it's a Really
Bad Way to do things in a live production environment.

(Plus you're missing a closing > in your example)
But now I have a new problem!

Only part of the text shows up! Is there a limit to the number of
characters that a Node(?) can return?
No.
It cuts off mid sentence, no
special charaters nearby. You can take a look here:
http://www.ivan-isabel.com/test/test.xml <- XML datastore
http://www.ivan-isabel.com/test/articles.php <- PHP/XML version (cut
off text)
http://www.ivan-isabel.com/articles.html <- Static version (full text)


I don't use PHP, so this is not clear to me.

///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
Jul 20 '05 #8
Irvin wrote:
Thanks for your help on this.
With regards to CDATA, the <p> tags seem to be presented well in the
browser. It doesn't appear to break anything. If I take them out I
loose my paragraph style and end up with one long paragraph.
That's because you have insufficient markup.

If your users want to make the output look pretty (bold, italics, etc
for only decoration) then forget XML, tell them to use Dreamweaver.

If your users want to use bold, italics, etc to highlight something
important (names, places, quotations, references, etc) then use some
markup which describes that reason, and use XSLT to translate it to
HTML with CSS for display. This will last much longer, because later
on you'll be able to use the same markup to guide transformation to
other formats for other purposes without having to change it.
I will post this whole issue with a PHP/XML forum and see what they
say.


I shudder to think :-)

///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
Jul 20 '05 #9

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

Similar topics

1
7381
by: Nikola Pecigos | last post by:
Hi, I have the following problem: We have an Oracle 9.2 with one table "document" which contains a path to the filesystem. If I want to index these files (HTML, PDF, World, Excel, etc.), I have to use the datastore type "FILE_DATASTORE". Another table "lng_text" stores the titles and descriptions for multiple languages for each row in table "document".
0
510
by: Irvin | last post by:
I am using an xml file to store data. I can get the data out now, but I have a problem with any field that needs text formatting such as bold, carriage return/linefeed, htmls tags. Can some one point me to a good tutorial that will help me learn this, or give me an example? Thanks, Irvin.
2
1933
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with formatting to another program. The help file reads: "Formula One maintains its own internal clipboard and also supports text on the Windows clipboard. The internal clipboard is more flexible than the Windows clipboard. The internal clipboard...
4
3131
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the background colour. In A2000 it works great, but in A2003 the background doesn't always change and when it does it only changes when the record looses the focus. Any way around this? Is it a bug? Or have they "improved" it?
3
2191
by: James Geurts | last post by:
This is probably more of an ASP.Net situation rather than c#, but since all of my code behind is in c#, maybe it fits here. I'm wondering, generally, at what point is it too inefficient to store information in a client cookie rather than retrieve it from a datastore. Now, I see the advantage of not storing it in a cookie, but a lot of programs already use cookies to store things from user credentials (roles) to specific user settings....
1
3824
by: Nathan Franklin | last post by:
hello list, i am writing a pocket pc project. just this morning i opened up my project and I got the following error.. error retrieving information from user datastore. and then the project could not be opened because it refers to a device platform that
14
4318
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my unformatted data values (as decimals) just fine, so I know there's not a problem with the data retrieval, just the formatting. I have read that this would work: lblPrice.Text = prodRow.ToString("C");
1
1666
by: aman909 | last post by:
Hello, Im trying to use conditional formatting in a text box on a form. What im trying to do is that conditional formatting changes the colour of the text in the text box. I need the conditional formatting to look up another text box. This is what i need: i have one text box which is called colour and it shows various colours. What i would like to do is in the other text box with conditional formatting is for the text box to change...
3
1363
by: v4vijayakumar | last post by:
Google appengine datastore is not very clear, and I couldn't get much from API documents. It would be very helpful if there are some more detailed documents with examples. Django provides very good documentation, but I don't know how much it is compatible with google appengine. Google appengine examples are not using datastore extensively, so this is also not helping much in modeling datastore. wiki.py is using low level APIs, this...
0
8290
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
8815
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8708
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
8489
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
8594
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...
1
6161
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
5622
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
4149
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
4294
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.