#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    98
    Rep Power
    13

    How could I turn this into a document manager?


    I made this XMl template for the purpose of organizing my articles, tutorials, and such for my site. Later on I will build a search engine for my site that I will utilize in searching for these articles with.

    However, for the time being, I just need to put my articles in XML. Should I use PHP and/or XSL to parser it? Also, would a DTD be needed for the kind of tags and stuff that I'm using?

    <?xml version="1.0" encoding="utf-8"?>

    <document type="article,tutorial,editorial,snipplet">

    <header>Title of the Document</header>

    <date_written year="2002">August 25, 2002</date_written>

    <content language="html,css,dhtml,php,java,javascript,xml,none">
    Here is where the content of my document will go. Whether it's a article, tutorial, or just a piece of my mind, this is where it'll reside.
    </content>


    </document>


    *Guess I ought to explain what the tags means!*

    Anyway the document tag has type= in it so I can describe what kind of document it'll be. (All kinds are in the tag) So, I I right a editorial about Linux, I would set <document type= to "Tutorial".

    The <header> is just a title.

    <date_written>Is for the date I publish a certain document. The year= attribute is for the aformentioned aid in searching.

    Content language is for the tutorial, articles, or code snippets I make for a particular language (like DHTML or PHP). I also have none just in case my document is a rambling rant or something.

    Phew! Alright, I'm done. Any suggestions on this is very appreciated. And if you have additional tags/attributes that might be of use, please do tell!
    Last edited by Mobius Man; August 25th, 2002 at 12:54 AM.
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Yes, you should use some sort of xslt engine to turn your article into html/wml/pdf/txt/doc/other-obscure-format for display

    No, you don't need a dtd. You might want one, since it will help you find errors in your documents that cause them to display incorrectly, but you don't need one. After you get the format worked out and few articles created so the bugs are worked out, then you can go back and make a dtd. Before that it's really not worth the effort.

    You might want to include an author tag, though that depends on how you're going to use your system.

    You'll probably want to give some thought to markup within your content, too. This probably isn't necessary, but stuff like headings, quotes, code snippets, pictures, and links could all be useful. Remember, if you're going to need to be able to search for it later, you're going to want a tag for it.
    Last edited by bricker42; August 25th, 2002 at 06:32 AM.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    98
    Rep Power
    13
    Alright, thanks for the tips. I do have one other question, though. How would I go about adding, say, links or images within an article in XML?
  6. #4
  7. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    I'd say duplicate the syntax of the html tag, but give it a more descriptive name. So <link url="ht...">blah</link> and <image source="foo.jpg" width="60" height="200057"/>. Remember, these are references for your xslt to turn into whatever tags are required by your display medium.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    98
    Rep Power
    13
    So I would use XSL to turn the <image source="foo.jpg" width="60" height="200057"/> inot a tag like the Html IMG tag?
  10. #6
  11. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Ya.
  12. #7
  13. Will develop for food.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Croatia
    Posts
    14
    Rep Power
    0
    Originally posted by Mobius Man
    So I would use XSL to turn the <image source="foo.jpg" width="60" height="200057"/> inot a tag like the Html IMG tag?
    This is the thing that really bothers me in XML/XSLT... If I write the following code (just an example):

    Code:
    <document>
    blahblahblah my document goes here and it's really cool :)
    <image src="myimg.gif" width="100" height="200" />
    here's the rest of my document...
     </document>
    How would I use XSLT to transform that? I read a few things about XSLT, but never found a solution for this question.
  14. #8
  15. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Code:
    <xsl:template match="text()">
      <xsl:value-of select="."/>
      <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="/document/image">
      <img src="{@src}" width="{@width}" height="{@height}"/>
    <xsl:template>
    Last edited by bricker42; August 31st, 2002 at 05:19 AM.
  16. #9
  17. Will develop for food.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Croatia
    Posts
    14
    Rep Power
    0
    Thanks, bricker42, I'll try it!

IMN logo majestic logo threadwatch logo seochat tools logo