Project

Profile

Help

Saxon and JTidy

Added by Anonymous over 16 years ago

Legacy ID: #4731956 Legacy Poster: noamk (nkrendel)

Hi, I'm trying to use Saxon 9 to do queries on output from jTidy. I run saxon by creating a saxon.sh bash script with the following lines: ------------------ #!/bin/bash java -cp saxonb9/saxon9.jar:saxonb9/saxon9-xqj.jar net.sf.saxon.Query $1 $2 $3 $4 ------------------ The first few lines of the file I'm trying to query are: ------------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html dir="ltr" lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content="HTML Tidy, see www.w3.org" /> ------------------ And when I run a simple query on it by using: ./saxon.sh -s:f.xhtml q3.xql I get just one line of output: <?xml version="1.0" encoding="UTF-8"?> When I add this exact xml line to the top of the file, I get the same output, just this one xml tag as output. I'm stumped at the moment and not sure where to go from here. Any help would be greatly appreciated.


Replies (4)

Please register to reply

RE: Saxon and JTidy - Added by Anonymous over 16 years ago

Legacy ID: #4732171 Legacy Poster: Michael Kay (mhkay)

If you want help debugging your query, then you'll have to show us your query. (However, for general help with XQuery coding it's best to ask on the list, unless there's something specific to Saxon in your question.) If you're new to XML/XQuery, the chances are that you forgot to specify the XHTML namespace in your query. Remember that all elements are in this namespace, and unless you declare the namespace in your query then names won't match.

RE: Saxon and JTidy - Added by Anonymous over 16 years ago

Legacy ID: #4732582 Legacy Poster: noamk (nkrendel)

Thanks for the quick reply. As I'm just starting with XQuery and Saxon, I was trying a very simple query: ------- (: This is a comment :) <data_tables> { //table } </data_tables> ------- I didn't know I could specify the XHTML namespace in the query. I'll try to look for information on that. Thanks!

RE: Saxon and JTidy - Added by Anonymous over 16 years ago

Legacy ID: #4732890 Legacy Poster: Michael Kay (mhkay)

That query searches for table elements that aren't in a namespace. To search for table elements in the XHTML namespace use declare namespace x="http:// (the XHTML namespace)"; <data_tables> { //x:table } </data_tables>

RE: Saxon and JTidy - Added by Anonymous over 16 years ago

Legacy ID: #4737240 Legacy Poster: noamk (nkrendel)

Thanks again for the help and very quick reply!!

    (1-4/4)

    Please register to reply