tags:

views:

100

answers:

5

Starting a new project and was planning on storing all of my web content in XML. I do not have access to a database so this seemed like the next best thing. One thing I'm struggling with is how to structure the XML for links (which will later be transformed using XSLT). It needs to be fairly flexible as well. Below is what I started with, but I'm starting to question it.

<links>
    <link>
        <url>http://google.com&lt;/url&gt;
        <description>Google</description>
    <link>
    <link>
        <url>http://yahoo.com&lt;/url&gt;
        <description>Yahoo</description>
        <links>
            <url>http://yahoo.com/search&lt;/url&gt;
            <description>Search</description>
        </link>
    <link>
</links>

That should get transformed into

Google Yahoo Search

Perhaps something like this might work better.

<links>
    <link href="http://google.com"&gt;Google&lt;/link&gt;
    <link href="http://yahoo.com"&gt;Yahoo
        <link href="http://yahoo.com/search"&gt;Search&lt;/link&gt;
    </link>
</links>

Does anyone perhaps have a link that talks about structuring web content properly in XML?

Thank you. :)

+1  A: 

I would be tempted to use something like:

<links>
  <link url="http://google.com" text="Google"/>
  <link url="http://yahoo.com" text="Yahoo">
    <links>
      <link url="http://yahoo.com/search" text="Search"/>
    </links>
  </link>
</links>

(although the inner <links> is optional and could be removed so you had links/link/link)

Marc Gravell
+1. I would remove the inner "Links" element, too. It's superfluous.
Tomalak
I'm confused. :|How can I tell if a list is nested if I don't have the inner <links>?
Mike
@Mike - just look what the containing element is.
Marc Gravell
A: 

For links, check XLink.

lexicore
A: 

Please ignore this answer (only leaving it in for legacy)

I think you should have a look at JAXB (http://java.sun.com/webservices/docs/2.0/tutorial/doc/JAXBUsing.html) which is included in Java 6. It defines a standard for translating between Java objects and XML.

javax.xml.bind
Thomas
What does JAXB have to do with this?
lexicore
@lexicore: Nothing - sorry, my bad. I was under the impression I was in a Java related thread :-(
Thomas
A: 

Are you sure about using XML as a database? See: http://stackoverflow.com/questions/201568/when-would-i-use-xml-instead-of-sql

“XML is not a database. It was never meant to be a database. It is never going to be a database. Relational databases are proven technology with more than 20 years of implementation experience. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one.“

compie
While I agree, the problem is that I do not have access to any types of database for this project. SQLLite isn't even an option either. Only reason I resorted to XML is to quickly be able to transform the file with XSLT. I want to stay away from having every web page a static file with content.
Mike
A: 

See the representation used in FXSL for lists here.

Dimitre Novatchev