xsl-list
[Top] [All Lists]

Re: [xsl] Does XQuery allow you to modify the XML? (remove elements, modify element values)

2019-10-18 16:56:49
Hi,

I too have had some success embedding XSLT in XQuery inside BaseX.

Here is a demo project, showing BaseX and XSLT inside Docker -
https://github.com/wendellpiez/XMLLunchbox. It includes a demo
application that uses XQuery and XSLT to draw an I Ching hexagram
thrown at random (with yarrow stalk probabilities). I am not running
Docker on a server on the open web so with my apologies, you will have
to run it yourself. But the code is all there.

NB this is server-side Saxon, as opposed to the demonstrations in the
XMLJellySandwich repository, which use SaxonJS in your browser (and
hence require no setup at all).

Of course, both can also be used together -- BaseX can serve up SaxonJS --

Cheers, Wendell

 Of course, you don't need Docker if you want to install and run BaseX natively.

On Fri, Oct 18, 2019 at 11:52 AM Steven D. Majewski
steve(_dot_)majewski(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
wrote:

BaseX had an XSLT module, so you can use both methods where appropriate.
By default, it uses Java XSLT 1.0, but if you drop Saxon into /lib, it will 
use that and give you XSLT 2 and 3.

I’m using (WIP) RESTXQ and typeswitch to dispatch on document root node to 
XSLT transform for that document type. You can also easily chain transforms 
together, and I’m trying to use this separate local customizations and 
branding to separate transforms. This also allows preprocessing to deal with 
namespaces schema based documents vs non-namespaces DTD based docs, or other 
version differences ( TEI P4 vs P5  ) with a normalization/conversion step. 
You can also easily mix XSLT transforms and XQuery functions in a chain.   
I’m also looking at trying to use Query to access sections of document ( like 
chapters ) and to use XSLT to transform to HTML instead of transforming 
complete document.


— Steve M.



On Oct 17, 2019, at 12:51 PM, Adam Retter 
adam(_dot_)retter(_at_)googlemail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Yes, you can either write a type-switch transformation in XQuery to
create a new document by filtering the content of your original
document, or you could use XQuery Update if your processor supports
it.

For typeswitches, this might be useful -
https://en.wikibooks.org/wiki/XQuery/Typeswitch_Transformations

On Thu, 17 Oct 2019 at 16:55, Costello, Roger L. costello(_at_)mitre(_dot_)org
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:


Hi Folks,

It's been a long time since I've looked at XQuery.

I need to identify certain elements in XHTML documents and then either remove 
the elements or modify their values. Can XQuery do this? Are there fee XQuery 
tools?

XHTML --> XQuery --> XHTML' (a modified version of the input XHTML document)

/Roger




--
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk


XSL-List info and archive
EasyUnsubscribe (by email)



-- 
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>