I'm stuck with the seemingly simple XQuery workout.
& lt; Ship & gt; & Lt; Class name = "congo" type = "BC" country = "Japan" number = "8" bore = "14" displacement = "32000" & gt; & Lt; Ship name = "Kongo" has been launched = "1913" /> & Lt; Ship name = "hai" has been launched = "1914" /> & Lt; Ship's name = "Kirishma" has been launched = "1915" & gt; & Lt; Action result = "drown" & gt; Guadalancalan & lt; / Battle & gt; & Lt; / Ships & gt; & Lt; Ship name = "Haruna" has been launched = "1915" /> & lt; / Class & gt; & Lt; / Ships & gt; I am trying to convert XML into an XHTML as a header with class name attributes (Congo) and an enumerated list of hair ship names and launch-year: < / P>
& lt; H1 & gt; Congo & lt; / H1> & Lt; Table & gt; & Lt; TR & gt; & Lt; Th & gt; Name & lt; / Th & gt; & Lt; Th & gt; Start & lt; / Th & gt; & Lt; TR & gt; & Lt; TR & gt; & Lt; TD & gt; Congo & lt; / TD & gt; & Lt; TD & gt; 1913 & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Hiei & lt; / TD & gt; & Lt; TD & gt; 1914 & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Kirishima & lt; / TD & gt; & Lt; TD & gt; 1915 & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Haruna & lt; / TD & gt; & Lt; TD & gt; 1915 & lt; / TD & gt; & Lt; / TR & gt; & Lt; H1 & gt; Next class name & lt; / H1> .... I am stuck with the following nested return - FLOWR XQuery:
declare option output "method = xml"; Declare option output "doctype-public = - // w3c // dtd xhtml 1.0 strict // n"; Declare option output "doctype-system = http: //www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; Declare option output "omit-xml-declaration = no"; Announce option output "indent = yes"; & Lt; Html xml: lang = "en" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; XQ-7 & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; {$ Class in doc ($ x / mm / battleships.xml) / ships / give class $ cname: = data ($ class / @name) $ sname: = $ slaunched data ($ square / ship / name) $: = Data ($ Square / Ship / @ Launch) returns & lt; H1 & gt; {$ Cname} & lt; / H1> & Lt; Table & gt; {$ Dock ("xmlbattleships.xml") / ship / class / ship where the data ($ ship /../@ name) eq $ cname $ sname give: $ data ($ ship / @name) $ slaunched: = Data ($ ship / @ launch) Returns & lt; Tr & gt; & Lt; Td> {$ Sname} & lt; / Td> & Lt; TD & gt; {$ Slaunched} & lt; / Td> & Lt; / Tr & gt; } & Lt; / Table & gt; } & Lt; / Body & gt; & Lt; / Html & gt;
I think the problem you're stuck with is that return An element is needed or a sequence when you & lt; H1 & gt; more and lt; Table & gt; Use a sequence here: Return ( {c $} & lt; / h1 & gt; Return to & amp; Lt; table & gt; [snip]) After the headline tag, look for both the brackets and the colon. With my where section I was transferred to a payday. Your desired output is not valid XHTML: You must close the table before the header. You will also get a table in place of an enumeration, what are you actually looking at?
This clean and fixed code works for me, I snatched your documents and some announcements, but you can find the changes:
& lt; Html xml: lang = "en" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; XQ-7 & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; {$ Class in / ships / class let $ cname: = data ($ square / @name) $ $ sname: = data ($ square / ship / @name) let's $ slaunched: = data ($ square / ship / @ Launched ($ 1) ($ 1 / $ 1), <$ cname} , & lt; Table & gt; {$ ship in / ships / class / ship} [$ namename = $ Cname] @name) $ slaunched: = data ($ ship / @ launch) returns & lt; Tr & gt; & Lt; Td> {$ Sname} & lt; / Td> & Lt; TD & gt; {$ Slaunched} & lt; / Td> & Lt; / Tr>} & lt; / Table & gt;)} & lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment