How To Execute An XQuery Against Numerous Documents
Issues related to W3C XQuery.
-
- Posts: 99
- Joined: Thu Oct 23, 2008 6:29 am
How To Execute An XQuery Against Numerous Documents
I have created an XQuery to identify erroneous nodes and line numbers they're on for a single document. It looks something like this:
for $name in doc("doc01.xml")//*[@SomeRandomAttribute="SomeRandomValue"]
where fn:count($name/elementThatMustExist)=0
return <match filename="{fn:tokenize(fn:base-uri(), "/")[fn:last()]}" node="{fn:name($name)}" line="{saxon:line-number($name)}"/>
My issue is that I have hundreds of files, and I do not want to edit this hundreds of times. I cannot simply do something like this: doc("*.xml").
Do I have any other options here?
TIA
for $name in doc("doc01.xml")//*[@SomeRandomAttribute="SomeRandomValue"]
where fn:count($name/elementThatMustExist)=0
return <match filename="{fn:tokenize(fn:base-uri(), "/")[fn:last()]}" node="{fn:name($name)}" line="{saxon:line-number($name)}"/>
My issue is that I have hundreds of files, and I do not want to edit this hundreds of times. I cannot simply do something like this: doc("*.xml").
Do I have any other options here?
TIA
-
- Posts: 99
- Joined: Thu Oct 23, 2008 6:29 am
Re: How To Execute An XQuery Against Numerous Documents
I believe I got this partially working now with a minor change as follows:
for $name in collection("file:///c:/Temp?select=*.xml")//*[@SomeRandomAttribute="SomeRandomValue"]
where fn:count($name/elementThatMustExist)=0
return <match filename="{fn:tokenize(fn:base-uri(), "/")[fn:last()]}" node="{fn:name($name)}" line="{saxon:line-number($name)}"/>
The issue I face now is that the fn:base-uri() function is returning the same document and not the current one from the collection. This makes the results I get useless.
for $name in collection("file:///c:/Temp?select=*.xml")//*[@SomeRandomAttribute="SomeRandomValue"]
where fn:count($name/elementThatMustExist)=0
return <match filename="{fn:tokenize(fn:base-uri(), "/")[fn:last()]}" node="{fn:name($name)}" line="{saxon:line-number($name)}"/>
The issue I face now is that the fn:base-uri() function is returning the same document and not the current one from the collection. This makes the results I get useless.
-
- Posts: 99
- Joined: Thu Oct 23, 2008 6:29 am
Re: How To Execute An XQuery Against Numerous Documents
I resolved this on my own.
The solution was the following:
for $name in collection("file:///c:/Temp?select=*.xml")//*[@SomeRandomAttribute="SomeRandomValue"]
where fn:count($name/elementThatMustExist)=0
return <match filename="{fn:document-uri(fn:root($name))}" node="{fn:name($name)}" line="{saxon:line-number($name)}"/>
One last thing that I cannot seem to figure out--
Is there a way that I can expand the line length of the output sequence in oXygen 13? My output from this XQuery is being wrapped at something like 80 characters. There is no need to wrap at all, since I have a wide screen. It makes it difficult to read the results.
The solution was the following:
for $name in collection("file:///c:/Temp?select=*.xml")//*[@SomeRandomAttribute="SomeRandomValue"]
where fn:count($name/elementThatMustExist)=0
return <match filename="{fn:document-uri(fn:root($name))}" node="{fn:name($name)}" line="{saxon:line-number($name)}"/>
One last thing that I cannot seem to figure out--
Is there a way that I can expand the line length of the output sequence in oXygen 13? My output from this XQuery is being wrapped at something like 80 characters. There is no need to wrap at all, since I have a wide screen. It makes it difficult to read the results.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How To Execute An XQuery Against Numerous Documents
Hi Jamil,
We cannot reproduce the problem with the line width for the result being limited to 80 chars. Probably the XML input files over which you are running the collection query have line widths in their content.
Regards,
Radu
We cannot reproduce the problem with the line width for the result being limited to 80 chars. Probably the XML input files over which you are running the collection query have line widths in their content.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 99
- Joined: Thu Oct 23, 2008 6:29 am
Re: How To Execute An XQuery Against Numerous Documents
Here is a screenshot: http://www.file-shop.com/Images/Misc/oXygen_sc.gif
The unneeded attribute wrapping behavior is consistent with both the standalone editor and the Eclipse plug-in. I can find no way to prevent this from happening. I can find no way to specify a line length for documents created via transformation.
There are work-arounds for this, of course (like saving the transformation results as an XML file). Even then I have to manually format the file to remove the wrapped lines. I do not wish to configure oXygen to format every opened XML document (which would take care of the wrapping in this case), because I do not want all XML docs modified upon opening.
The unneeded attribute wrapping behavior is consistent with both the standalone editor and the Eclipse plug-in. I can find no way to prevent this from happening. I can find no way to specify a line length for documents created via transformation.
There are work-arounds for this, of course (like saving the transformation results as an XML file). Even then I have to manually format the file to remove the wrapped lines. I do not wish to configure oXygen to format every opened XML document (which would take care of the wrapping in this case), because I do not want all XML docs modified upon opening.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How To Execute An XQuery Against Numerous Documents
Hi Jamil,
I reproduced the behavior, line breaks are inserted before long attributes.
The only preference we have for formatting is in the Oxygen Preferences->
XML / XSLT-FO-XQuery / XQuery page.
The checkbox is called Format transformer output.
This setting we set to the Saxon 9 XQuery processor and the indentation (and line breaking) is performed exclusively by it.
Unfortunately if you uncheck the checkbox, everything will be outputted on one line.
From what I've checked in the XQuery processor code, the line break for attributes is hard coded to 80 chars so the only option for you is to automatically save the XQuery result to an XML file, open the file and format and indent it in Oxygen.
Regards,
Radu
I reproduced the behavior, line breaks are inserted before long attributes.
The only preference we have for formatting is in the Oxygen Preferences->
XML / XSLT-FO-XQuery / XQuery page.
The checkbox is called Format transformer output.
This setting we set to the Saxon 9 XQuery processor and the indentation (and line breaking) is performed exclusively by it.
Unfortunately if you uncheck the checkbox, everything will be outputted on one line.
From what I've checked in the XQuery processor code, the line break for attributes is hard coded to 80 chars so the only option for you is to automatically save the XQuery result to an XML file, open the file and format and indent it in Oxygen.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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