John Bishop
BAN USER- 0 Answers designing DTDs and writing XQueries
You are given the following specication: Each part is a simple part or a composite part. A simple part has a name and a price. A composite part has a name and contains a number of component subparts, which are simple or composite. The subparts of a component subpart x of y are also (recursively) subparts of y. You can assume that the part names are unique.
- John Bishop March 13, 2014
To do:
Design a DTD D1 reflecting the hierarchical structure of this specication.
Debug the DTD using an online XML validation tool. Document the results.
Write an XQuery query that returns the names of all the subparts of each part whose name contains "wheel."
Write an XQuery query that returns the names of the complex parts that have no simple subpart that costs over $100.
Dene an XQuery function that, given the name of a part, calculates its total cost (the sum of the costs of its simple subparts).
Design a relational-like DTD D2 for the specication. That is, part/subpart relationship and part price should be viewed as relations and represented using some XML encoding of relations.
Write an XQuery mediator query M12 that maps documents valid under D1 into documents valid under D2.
Run the mediator M12 on an example database given separately. Use an available online XQuery system. Document the results.| Flag | PURGE - 0 Answers logic program for stratified datalog
Assume a directed graph is represented as a set of facts of the form node(x) for a node x, and edge(x; y) for an edge (x; y). A node x is red if there is a fact red(x). If possible, formulate the following queries in Datalog. If this is not possible, explain why, and formulate the query in Stratied Datalog not, proving that the resulting program is stratied. The programs can share rules but you have to clearly indicate which rules belong to which program.
- John Bishop March 13, 2014
Write a logic program P1 that returns the nodes x such that there is a path from x to a red node.
Write a logic program P2 that returns the pairs (x; y) such that there is a path from x to y that does not include a red node.
Write a logic program P3 that returns the pairs (x; y) such that every path from x to y includes a red node.
Construct a graph G such that P2 and P3 return at least one answer each.
Run P2 and P3 on the set of facts representing G, using xsb. Document the runs.| Flag | PURGE