zsh-workers
 help / color / mirror / code / Atom feed
* xpath
@ 2008-04-04 16:01 Jack Bates
  2008-04-05 21:03 ` xpath Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Jack Bates @ 2008-04-04 16:01 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

I have need of a shell which supports *some* XPath syntax - specifically
that for handling attributes. zsh is currently my shell of choice, and
is quite powerful - I wonder if I can configure zsh to support this
syntax?

I have a content repository mounted on my filesystem. Attributes are
mapped to filesystem extended attributes. I want to use XPath
expressions like: /myrepo/subdir/*[@user.repository_id = a16]

- which should match all entries in /myrepo/subdir which have an
extended attribute named user.repository_id with value a16

I found a paper discussing XPath and filename expansion:
http://dret.net/netdret/docs/wilde-www2006-namespaces.pdf

- and the implementation from the paper: http://xpsh.sourceforge.net/

I also found an article on zsh and querying extended attributes:
http://72.14.253.104/search?q=cache:pCxLBopsSmQJ:www.linux-mag.com/id/2126

This is a simple introduction to XPath:
http://zvon.org/xxl/XPathTutorial/General/examples.html

XPath is used by the Java content repository API for traversing
hierarchical resources, which is part of my motivation:
http://en.wikipedia.org/wiki/Content_repository_API_for_Java

Thanks and best wishes, Jack

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: xpath
  2008-04-04 16:01 xpath Jack Bates
@ 2008-04-05 21:03 ` Peter Stephenson
  2008-04-05 23:47   ` xpath Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2008-04-05 21:03 UTC (permalink / raw)
  To: zsh-workers

On Fri, 04 Apr 2008 09:01:22 -0700
Jack Bates <ms419@freezone.co.uk> wrote:
> I have need of a shell which supports *some* XPath syntax - specifically
> that for handling attributes. zsh is currently my shell of choice, and
> is quite powerful - I wonder if I can configure zsh to support this
> syntax?
> 
> I have a content repository mounted on my filesystem. Attributes are
> mapped to filesystem extended attributes. I want to use XPath
> expressions like: /myrepo/subdir/*[@user.repository_id = a16]

Just to be clear: do you need *exactly* xpath syntax, as given above?
If so, then the answer is no: this conflicts with ordinary shell syntax
where [...] specifies a character class and since any set of characters
can appear within it there's no way of interpreting it any other way.
Or are you happy with something that looks a bit like xpath syntax, and
can be converted (possibly automatically) into it?  If the latter, we
could probably come up with something using shell functions and glob
qualifiers.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: xpath
  2008-04-05 21:03 ` xpath Peter Stephenson
@ 2008-04-05 23:47   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2008-04-05 23:47 UTC (permalink / raw)
  To: zsh-workers

On Apr 5, 10:03pm, Peter Stephenson wrote:
} Subject: Re: xpath
}
} On Fri, 04 Apr 2008 09:01:22 -0700
} Jack Bates <ms419@freezone.co.uk> wrote:
} > I have a content repository mounted on my filesystem. Attributes are
} > mapped to filesystem extended attributes. I want to use XPath
} > expressions like: /myrepo/subdir/*[@user.repository_id = a16]
} 
} Just to be clear: do you need *exactly* xpath syntax, as given above?

That's not a very representative sample of xpath syntax.  Inside the
[ ] can be an arbitrarily complex expression, with parentheses for
grouping, function calls with their argument lists in parentheses,
logical operators, etc.  (If you enjoy attempting to make sense of
impenetrable descriptive prose, try <http://www.w3.org/TR/xpath>.
It can't be any harder than, say, understanding Sven's C code in the
completion modules.)

} If so, then the answer is no: this conflicts with ordinary shell syntax
} where [...] specifies a character class and since any set of characters
} can appear within it there's no way of interpreting it any other way.

It's worse than that, isn't it?  Spaces inside the [ ] would cause the
parts of the pattern to be interpreted as separate words.  Anyway, the
application of the predicate inside the [ ] is dependent on the syntax
of the path that precedes it; it's applied as a filter, quite like zsh's
(e[...]) glob qualifier, really.

} Or are you happy with something that looks a bit like xpath syntax, and
} can be converted (possibly automatically) into it?  If the latter, we
} could probably come up with something using shell functions and glob
} qualifiers.

Indeed, given an external program that interprets the predicate syntax,
I think it'd be fairly easy to write something with (e) to apply it.
It'd look something like

/myrepo/subdir/*(e{'reply=($(xpred $REPLY "[@user.repository_id = a16]"))'})

assuming xpred takes a filename and a predicate and outputs the list of
whatever it is from the file.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-05 23:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-04 16:01 xpath Jack Bates
2008-04-05 21:03 ` xpath Peter Stephenson
2008-04-05 23:47   ` xpath Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).