New to XML

Discussion in 'XML' started by MS, Feb 16, 2005.

  1. MS

    MS Guest

    I am brand new to XML and doing some practice stuff. I am missing a
    simple concept and I am hoping someone can shed some light.

    I am learning how to tie in HTML and XML but everything I have done so
    far, the XML file has resided in the same directory on my local pc.

    Can you retrieve or view XML files via the web from another location
    and display them in an HTML document using noting but HTML? If so, how
    do you query this data?
    MS, Feb 16, 2005
    1. Advertisements

  2. MS

    Paulo Pinto Guest

    If you're using a browser that's easy.
    Just use CSS for formating. the presentation.

    But what do you mean by 'querying the data'?
    Where do you want to do that?
    Paulo Pinto, Feb 18, 2005
    1. Advertisements

  3. MS

    Peter Flynn Guest

    Yes, just upload them to your web server. Make sure your server operator
    or webmaster has set the mime.types file to serve .xml files correctly
    (see the FAQ for details:

    You'll need to write a CSS stylesheet to go with them, otherwise they
    will be displayed unformatted. Browsers have no built-in formatting rules
    for XML like they do for HTML, so a stylesheet is essential if you want
    the document formatted.
    To do this you have three choices:

    a) use XML files with XSLT stylesheets on with server that does XML to HTML
    conversion, such as AxKit, Cocoon, or PropelX.

    b) use XML files with XSLT stylesheets that get downloaded by the user's
    browser and converted in the browser (currently restricted to recent
    browsers only: MSIE5/6, Mozilla Firefox, Opera [Safari and Konqueror
    to follow soon, I believe]) so users of older browsers will be SOOL.

    c) use XHTML, but serve the file as MIME type text/hmtl. This is enough
    to fool most browsers, but you are imposing quite severe restrictions
    on yourself in terms of data identity and document management by using
    XHTML (unless you actually use some other form of XML and convert to
    XHTML statically before serving).
    That's a different thing altogether. If you just want to let users search
    it, you'll need an XML search engine (there's one with Cocoon called Lucene)
    but if you want them to be able to construct programmatic queries, you can
    either program an interface to let them do it (which means scripting the
    response-handler) or you can provide a selection of pre-programmed queries
    (eg in XSLT) to which they can provide data values. XQuery provides a
    syntax, but you'll need to write the surrounding code.

    Peter Flynn, Feb 19, 2005
  4. MS

    MS Guest

    For my query question, if I wanted to allow a user to query last names
    for 'Jefferson', is there a way to do this in XML?

    <?xml version='1.0'?>
    <?xml-stylesheet type="text/xsl" href="Names.xsl"?>
    <!DOCTYPE ListOfNames SYSTEM "Names.dtd">

    <ListOfNames lang="English">
    MS, Feb 23, 2005
  5. You said you use a DOM-approach.
    Once your data base grows too large, the DOM
    might become a problem. But a SAX-approach is
    quite adequate for simple queries like the one
    you mention. Here is a SAX-based solution i


    XMLCHARDATA { data = $0 }
    XMLENDELEM == "FirstName" { first = data }
    XMLENDELEM == "LastName" { last = data }
    XMLENDELEM == "Name" {
    if (last == "Jefferson")
    print first, last

    The output of this script is:

    Thomas Jefferson
    =?ISO-8859-1?Q?J=FCrgen_Kahrs?=, Feb 23, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.