XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: When the required output data can't be produced with a tool,does it indicate the XML document is poorly designed or a new tool is needed?

When I read the XML document, I did not perceive that genre had anything to do with the book elements contained in category. They are siblings.  Author is a clear child element.  If she wants to interpret the relationships between elements differently than understood by XPath, she needs to use another tool.  But in sticking with her XML document design, she should realize that the relationship she infers are not obvious to outsiders.

-Nora


-----Original Message-----
From: Costello, Roger L. [mailto:costello@mitre.org] 
Sent: Friday, September 24, 2010 9:39 AM
To: xml-dev@lists.xml.org
Subject: [xml-dev] When the required output data can't be produced with a tool, does it indicate the XML document is poorly designed or a new tool is needed?

Hi Folks,

A couple days ago a colleague brought the following problem to me.

She has this XML document:

<books>
    <category>
        <genre>Autobiography</genre>
        <book>
            <name>My Life and Times</name>
            <author>Paul McCartney</author>
        </book>
        <book>
            <name>The Beatles</name>
            <author>Paul McCartney</author>
        </book>
    </category>
    <category>
        <genre>Music</genre>
        <book>
            <name>Eight Days a Week</name>
            <author>Paul McCartney</author>
        </book>
    </category>
</books>

She is using XPath 1.0 to process the XML document (collect some data).

She has written multiple XPath expressions to collect various data from the XML document. She was able to successfully construct XPath expressions to create collect all the desired data, except for one.

Here's the data she was unable to collect using XPath 1.0: Select the value of <genre> for each <book> with <author> equal to 'Paul McCartney'. She needs an XPath 1.0 expression that will yield:

    Autobiography
    Autobiography
    Music

As it turns out, there is no XPath 1.0 expression that can be written to return the desired results. (I confirmed this with the XPath gurus on the xsl-list)


What should she do?


Let's summarize the situation: Here are the components comprising the situation:

1. DATA: The XML document

2. PROCESSING TOOL: A tool to process the XML document: XPath 1.0

3. RESULTS: Desired (required) results


I see 3 possible courses of action that my colleague could take:

a. Restructure the DATA so that the PROCESSING TOOL can generate the desired/required RESULTS. In other words, restructure the XML document so that an XPath 1.0 expression can be written that produces the desired/required results.

b. Use a different PROCESSING tool. Instead of using XPath 1.0 switch to, say, XPath 2.0.

c. Change the requirements on the RESULTS. Live with whatever XPath 1.0 can do.


Let's suppose (c) is not acceptable because the requirements are fixed. That leaves us with (a) and (b) -- restructure the XML document or change from XPath 1.0 to something else.

Here is an argument supporting (a):

    I believe what this problem illustrates is that the XML document 
    is not well designed. That is, it does not support the kinds of 
    operations that are required. I believe that a redesign of the 
    XML document is in order.

Here is an argument supporting (b):

    I believe what this problem illustrates is that the tool you are
    using (XPath 1.0) is not suitable for the tasks you need to perform. 


QUESTION

Is the problem that my colleague is having indicative of a poorly designed XML document or indicative of a poor selection of tool?


/Roger

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS