Extracting data from an XHTML file with XQuery
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 22
- Joined: Tue Apr 08, 2008 1:41 pm
Extracting data from an XHTML file with XQuery
Post by sampablokuper »
Hi all,
I have an XHTML document as follows:
which I call index.html .
I also have the following XQuery files:
which I call test_one.xquery, and:
which I call test_two.xquery .
When I use the XQuery debugging view in Oxygen, and select index.html as my XML file, test_one.xquery as my XQuery file and Saxon-B as my XQuery engine in the Control Toolbar, running the XQuery gives the following output:
But when I do the same thing with test_two.xquery selected instead, I get the following output:
Why is it that test_two.xquery gives no output (aside from the XML header line)?
Thanks in advance for your help!
Sam
I have an XHTML document as follows:
Code: Select all
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Foo</title>
</head>
<body>Bar</body>
</html>
I also have the following XQuery files:
Code: Select all
for $markup in /*
return $markup
Code: Select all
for $markup in /html/*
return $markup
When I use the XQuery debugging view in Oxygen, and select index.html as my XML file, test_one.xquery as my XQuery file and Saxon-B as my XQuery engine in the Control Toolbar, running the XQuery gives the following output:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Foo</title>
</head>
<body>Bar</body>
</html>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
Thanks in advance for your help!
Sam
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Extracting data from an XHTML file with XQuery
Post by sorin_ristache »
Hello,
You get an empty result with test_two.xquery because you did not specify the correct namespace for the html element. You should use a namespace declaration:
In test_one.xquery the * matches elements from any namespace.
Regards,
Sorin
You get an empty result with test_two.xquery because you did not specify the correct namespace for the html element. You should use a namespace declaration:
Code: Select all
declare namespace xhtml="http://www.w3.org/1999/xhtml";
for $markup in /xhtml:html/*
return $markup
Regards,
Sorin
-
- Posts: 22
- Joined: Tue Apr 08, 2008 1:41 pm
Re: Extracting data from an XHTML file with XQuery
Post by sampablokuper »
Hi Sorin,
Thanks for your help! That's fixed it for me
Sam
Thanks for your help! That's fixed it for me

Sam
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service