Capitains / Ahab

CTS5 XQuery database
1 stars 0 forks source link

Doesn't deal with complex xpath expressions #24

Closed sonofmun closed 8 years ago

sonofmun commented 8 years ago

See https://github.com/Capitains/inventory-maker/issues/13

The problem in Inventory Maker is fixed. Now

replacementPattern="#xpath(/tei:TEI/tei:text/tei:body/tei:div[@type='edition']/tei:div[@n='$1' and @subtype='section'])"

produces in the inventory

xpath="/tei:div[@n='?' and @subtype='section']"

Now the problem seems to be with the CTS API. When I do the following

http://localhost:8080/exist/restxq/cts?request=GetPassage&inv=latin&urn=urn:cts:latinLit:stoa0040.stoa029.opp-lat1:1

I get the following error in CTS 5 API XQ

Unsupported Xpath: /tei:TEI/tei:text/tei:body/tei:div[@type='edition']/tei:div[@n='1'
PonteIneptique commented 8 years ago

Related codeblock

This one is gonna be painful.

PonteIneptique commented 8 years ago

@balmas Would you like me to get this or would you think someone else (including you) should do it ?

sonofmun commented 8 years ago

It looks to me like the pertinent regexs are here and here. I don't know what effect changing these will have.

PonteIneptique commented 8 years ago

From what I can see, I'd tend to agree with you. And for what it can do... Well, it can basically destroy the CTS API :D

sonofmun commented 8 years ago

The problem seems to be that these regexes are only set up to deal with one @. What would happen if this

"^(.*?)(@[\w\d\._:\s]+)=[""']\?[""'](.*)$"

were changed to this

"^(.*?)((@[\w\d\._:\s]+)=[""']\?[""']\s?)+(.*)$"

or perhaps to this

"^(.*?)(?:(@[\w\d\._:\s]+)=[""']\?[""']\s?)+(.*)$"

I am not sure if the following would still work as planned, however:

fn:concat("$1", "$2", $startRange, " and ", "$2", $endRange, "$3")
PonteIneptique commented 8 years ago

You're right, if $startrange /$endRange is what we think, we might get into troubles here, We would then need to make sure this comes in $3 ?

sonofmun commented 8 years ago

$startrange /$endRange are not part of the regex, but are calculated here. I don't really understand how. But I would think that changing the regex should not affect either of them. Or am I completely wrong here?

PonteIneptique commented 8 years ago

Having a look at https://regex101.com/r/eE5dI3/1

It seems this might not be the good place to look at !

PonteIneptique commented 8 years ago

Do you have any line number when the error occurs ?

balmas commented 8 years ago

That's a cool regex testing tool... I was just about to say that I think the regex should work as long as there is only one attribute in the xpath template which is set to ='?'

PonteIneptique commented 8 years ago

regexpal is generally my best ... pal in this kind of situation...

sonofmun commented 8 years ago
<position>l 733, c 5</position>

But that is the location of the error message that it throws.

PonteIneptique commented 8 years ago

Can you print the inventory part of the CTS API for the text ? If required, check that there is no cache in the database for this precise file

sonofmun commented 8 years ago

Would that be the results of this

http://localhost:8080/exist/restxq/cts?request=GetPassage&inv=latin&urn=urn:cts:latinLit:stoa0040.stoa029.opp-lat1

i.e., no specific passage but the whole work?

PonteIneptique commented 8 years ago

Try : http://localhost:8080/exist/restxq/cts?request=GetCapabilities&inv=latin&urn=urn:cts:latinLit:stoa0040.stoa029.opp-lat1 or just find the specific passage removing the urn

sonofmun commented 8 years ago

The GetCapabilities call returns this for citationMapping

<ti:citationMapping>
<ti:citation label="section" xpath="/tei:div[@n='?'" scope="/tei:TEI/tei:text/tei:body/tei:div[@type='edition']"/>
</ti:citationMapping>

But the Inventory Maker page shows this

<ti:citationMapping>
<ti:citation label="section" xpath="/tei:div[@n='?' and @subtype='section']" scope="/tei:TEI/tei:text/tei:body/tei:div[@type='edition']"/>
</ti:citationMapping>

I am pretty sure that I cleared my cache correctly (Chrome: More Tools>Clear Browsing Data... and cleared all cached images and files from the past day). So is this a cache problem or a CTS API problem? Or do you need more information than just that?

PonteIneptique commented 8 years ago

Should we have a small hangout ?

sonofmun commented 8 years ago

The peer coding starts in 15 minutes, right?

PonteIneptique commented 8 years ago

Yup but probably lets debug this situation quickly before ?

sonofmun commented 8 years ago

This issue was caused by user error. There doesn't actually seem to be a problem. Closing now.