Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Ezilon Directory   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 03-29-2007, 04:37 PM   #1 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Style within an XML element

I'd like to use XML to store the content for a journaling program, but it's pretty drab. I don't have any problem generating the XML or using it with an XSL template. The issue I'm having is that I would like the user to be able to use simple formatting like bold and italics within a journal entry. For example (XML):
Code:
<journal> <note> <date>03/29/2007</date> <entry>Here is an entry in my journal</entry> </note> </journal>
I can format the whole <entry> as usual, but how can I get XML to recognize that one of the words within the <entry> should be bold?

I have no problem doing string replacement stuff, however I've not been able to implement any that work. I can Javascript it, replacing &lt; with <, for example. This invalidates the XML code (no < allowed), but even when it's in there, and I can see it in the code, the browser will not render is as bold ... it just ignores it.
Code:
<journal> <note> <date>03/29/2007</date> <entry>Here is an <b>entry</b> in my journal</entry> </note> </journal>
ends up as
Code:
03/29/2007 Here is an entry in my journal
I'm having a similar problem with line breaks within an entry ... <br /> just shows up without breaking the line, and actual carriage returns within an entry are ignored.

How can I get HTML instructions to render within an XML element?

Thoughts? Thanks in advance ...
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 03-31-2007, 09:38 AM   #2 (permalink)
Contributing Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 310
iTrader: 0 / 0%
Latest Blog:
None

exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
Why don't you store the journal entries in a database and output as HTML? Or, if you don't want to use a database, store as XML, and output as HTML.
exam is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-02-2007, 09:43 AM   #3 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Using a database is not an option here, and my question is about storing data as XML and then outputting it as HTML. How do you make a <b> tag work within an XML element? It's easy to bold-format the whole element ... but what about one word within the element's data? I haven't found a way ...
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-02-2007, 10:47 AM   #4 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Here are example files, hopefully to make the problem more clear:

journal.dtd
Code:
<!ELEMENT journal (entry+)> <!ELEMENT entry (date,text)> <!ELEMENT date (#PCDATA)> <!ELEMENT text (#PCDATA)>
journal.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="journal.xsl"?> <!DOCTYPE journal SYSTEM "journal.dtd"> <journal> <entry> <date>03/31/2007</date> <text>entry with <b>bold</b> word</text> </entry> </journal>
journal.xsl
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head><title>XSLT Test</title></head> <body> <xsl:for-each select="journal/entry"> <em><xsl:value-of select="date" /></em><br /> <xsl:value-of select="text" /> <hr /> </xsl:for-each> </body> </html> </xsl:template> </xsl:transform>
As you can see from this test, wrapping the entire element (in the XSL file) with EM tags formats that entire element as italics. However the <b> tags within the TEXT element are not acted on by the browser ... it just ignores them.

I'm trying to discover if I can use XML files for storing this type of data with modest formatting, or if I should continue to use the HTML files I've been using.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-03-2007, 03:40 PM   #5 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,804
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Send a message via Yahoo to Taltos
Wish I could help, James. I haven't messed with XML enough to know. I thought part of the purpose of XML was to separate content and formatting? Which means it wouldn't surprise me if you are out of luck on this one. Sounds like it will require a creative solution. You have already tried a few from your description but they all involve trying to put HTML formating into XML. I may be stating the obvious and just don't know enough to realize it.

It is sounding like you might have to output as HTML and using some kinds of flags that XML won't complain about, replace after it is in HTML with the HTML formatting tags. Sounds like a pain though. You got me curious now. Let me know how this adventure goes.
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-03-2007, 04:22 PM   #6 (permalink)
Inactive
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 678
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Here's what works for this:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head><title>XSLT Test</title></head> <body> <xsl:for-each select="journal/entry"> <em><xsl:value-of select="date" disable-output-escaping="yes" /></em><br /> <xsl:apply-templates/> <hr /> </xsl:for-each> </body> </html> </xsl:template> <xsl:template match="text"> <xsl:apply-templates/> </xsl:template> <xsl:template match="b"> <b><xsl:apply-templates/></b> </xsl:template> </xsl:transform>
Now I need to get it to work for other tags, like <br /> ... I think I may go back to HTML pages for storage, and then when I need the XML, I'll just output it and use it on the fly.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blogger Ad Element issue visionedger Blogging Forum 1 03-04-2008 06:54 PM
css help in element positioning. funguru Coding Forum 5 11-22-2006 08:37 PM
title element of a link seminfo SEO Forum 13 04-02-2006 01:08 AM
Sort on 3rd array element (PHP) jg_v7n Coding Forum 1 09-24-2004 08:44 AM
CSS block element without linefeed at its top and bottom? Dilandau Web Design Lobby 8 06-15-2004 08:27 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 06:25 AM.
© Copyright 2008 V7 Inc