[osis-core] Getting elements
Harry Plantinga
osis-core@bibletechnologieswg.org
Thu, 15 Aug 2002 11:10:30 -0400
I think Todd is right that there can be problems with looking
for "Z.1" with XPath in the example below. However, I think there
IS an XPath solution, without using the [] syntax. The XPath
code required is a bit messy, but that might be preferred by some
to a messy XML document. Also, I suspect the need won't arise
very frequently, since the problem doesn't arise if you only have
one osisID in an osisID attribute, and it's less likely to arise
if you don't do much mixing of different reference schemes.
So, here's how to search for Z.1 in the standard reference system
using basic XPath.
If you have a list of osisIDs like that below, but space separated
instead of using the [] notation, you can find Z.1 in the default
reference system by looking for osisID attributes
- equal to Z.1, or
- starting with "Z.1 ", or
- containing " Z.1 ", or
- ending with " Z.1".
There are starts-with() and contains() string functions. There
is no "ends-with()" function, but you can use substring() and
string-length() to get the same behavior.
-Harry
> I think that the following solves ALL of the problems posed
> below from the earlier post.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <x osisID="[T:Z.A] [Z.1]">
> <y osisID="[T:Z.1.1] [Z.1.1]">Z.1.1</y>
> <y osisID="[T:Z.1.2] [Z.1.2]">Z.1.2</y>
> <y osisID="[T:Z.1.2] [T:Z.1.3] [T:Z.1.4] [Z.1.3]
> [Z.1.4.A]">Z.1.3 and Z.1.4</y>
> <y osisID="[T:Z.1.4] [T:Z.1.5] [Z.1.4.B] [Z.1.5]">Z.1.4
> and Z.1.5</y>
> </x>
>