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
    1. Advertising

  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?


    "MS" <> wrote in message
    news:...
    > 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?
    >
    Paulo Pinto, Feb 18, 2005
    #2
    1. Advertising

  3. MS

    Peter Flynn Guest

    MS wrote:

    > 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


    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: http://www.ucc.ie/xml)

    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.

    > and display them in an HTML document using nothing but HTML?


    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).

    > If so, how do you query this data?


    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
    --
    "The cat in the box is both a wave and a particle"
    -- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
    Peter Flynn, Feb 19, 2005
    #3
  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">
    <Name>
    <FirstName>William</FirstName>
    <LastName>Thomas</LastName>
    </Name>
    <Name>
    <FirstName>Thomas</FirstName>
    <LastName>Jefferson</LastName>
    </Name>
    <Name>
    <FirstName>Mike</FirstName>
    <LastName>Jones</LastName>
    </Name>
    </ListOfNames>
    MS, Feb 23, 2005
    #4
  5. MS wrote:

    > 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?


    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
    XMLgawk:

    BEGIN { XMLMODE=1 }

    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
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    344
    Stylus Studio
    Jul 6, 2004
  2. Stylus Studio
    Replies:
    0
    Views:
    343
    Stylus Studio
    Jul 2, 2004
  3. Stylus Studio
    Replies:
    0
    Views:
    410
    Stylus Studio
    Jul 26, 2004
  4. Erik Wasser
    Replies:
    5
    Views:
    445
    Peter J. Holzer
    Mar 5, 2006
  5. Replies:
    2
    Views:
    448
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page