Revision: 22512
http://sourceforge.net/p/bibdesk/svn/22512
Author: hofman
Date: 2018-08-23 09:55:22 +0000 (Thu, 23 Aug 2018)
Log Message:
-----------
No need to catch xpath exception, all paths are fixed and checked, so they
should be valid XPath 1
Modified Paths:
--------------
trunk/bibdesk/BDSKArxivParser.m
trunk/bibdesk/BDSKIACRParser.m
trunk/bibdesk/DOMNode_BDSKExtensions.m
Modified: trunk/bibdesk/BDSKArxivParser.m
===================================================================
--- trunk/bibdesk/BDSKArxivParser.m 2018-08-23 06:30:38 UTC (rev 22511)
+++ trunk/bibdesk/BDSKArxivParser.m 2018-08-23 09:55:22 UTC (rev 22512)
@@ -103,49 +103,44 @@
DOMXPathExpression *journalNodePath = nil;
DOMXPathExpression *abstractNodePath = nil;
- @try {
- if (isAbstract) {
- arxivLinkNodePath = [[self domDocument]
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell
arxivid']" resolver:nil];
- arxivIDNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
-
- pdfURLNodePath = [[self domDocument]
createExpression:@"../div[@class='extra-services']/div[@class='full-text']/ul/li/a[contains(text(),'PDF')]"
resolver:nil];
- doiNodePath = [[self domDocument]
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell
doi']/a" resolver:nil];
-
- titleNodePath = [[self domDocument]
createExpression:@"./h1[contains(concat(' ',normalize-space(@class),' '),'
title ')]/span/following-sibling::text()" resolver:nil];
- authorsNodePath = [[self domDocument]
createExpression:@"./div[@class='authors']/a" resolver:nil];
- journalNodePath = [[self domDocument]
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell
jref']" resolver:nil];
- abstractNodePath = [[self domDocument]
createExpression:@"./blockquote[contains(concat(' ',normalize-space(@class),'
'),' abstract ')]" resolver:nil];
- } else if (isSearch) {
- arxivLinkNodePath = [[self domDocument]
createExpression:@"./div[contains(concat(' ',normalize-space(@class),' '),'
level ')]/p[contains(concat(' ',normalize-space(@class),' '),' list-title ')]"
resolver:nil];
- arxivIDNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
-
- pdfURLNodePath = [[self domDocument]
createExpression:@"./span/a[contains(text(),'pdf')]" resolver:nil];
- doiNodePath = [[self domDocument]
createExpression:@"../div/div/div/span[contains(text(),'doi')]/following-sibling::span/a"
resolver:nil];
-
- titleNodePath = [[self domDocument]
createExpression:@"./p[contains(concat(' ',normalize-space(@class),' '),' title
')]" resolver:nil];
- authorsNodePath = [[self domDocument]
createExpression:@"./p[@class='authors']/a" resolver:nil];
- journalNodePath = [[self domDocument]
createExpression:@"./p[contains(concat(' ',normalize-space(@class),' '),'
comments ')]/span[text()='Journal ref:']/following-sibling::text()"
resolver:nil];
- abstractNodePath = [[self domDocument]
createExpression:@"./p[contains(concat(' ',normalize-space(@class),' '),'
abstract ')]/span[contains(concat(' ',normalize-space(@class),' '),'
abstract-full ')]" resolver:nil];
- } else if (isList) {
- arxivLinkNodePath = [[self domDocument]
createExpression:@"./span[@class='list-identifier']" resolver:nil];
- arxivIDNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
-
- pdfURLNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'pdf')]" resolver:nil];
- doiNodePath = [[self domDocument]
createExpression:@"./div[@class='list-doi']/span/following-sibling::text()"
resolver:nil];
-
- arxivNodePath = [[self domDocument]
createExpression:@"./following-sibling::dd/div[@class='meta']" resolver:nil];
+ if (isAbstract) {
+ arxivLinkNodePath = [[self domDocument]
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell
arxivid']" resolver:nil];
+ arxivIDNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
+
+ pdfURLNodePath = [[self domDocument]
createExpression:@"../div[@class='extra-services']/div[@class='full-text']/ul/li/a[contains(text(),'PDF')]"
resolver:nil];
+ doiNodePath = [[self domDocument]
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell
doi']/a" resolver:nil];
+
+ titleNodePath = [[self domDocument]
createExpression:@"./h1[contains(concat(' ',normalize-space(@class),' '),'
title ')]/span/following-sibling::text()" resolver:nil];
+ authorsNodePath = [[self domDocument]
createExpression:@"./div[@class='authors']/a" resolver:nil];
+ journalNodePath = [[self domDocument]
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell
jref']" resolver:nil];
+ abstractNodePath = [[self domDocument]
createExpression:@"./blockquote[contains(concat(' ',normalize-space(@class),'
'),' abstract ')]" resolver:nil];
+ } else if (isSearch) {
+ arxivLinkNodePath = [[self domDocument]
createExpression:@"./div[contains(concat(' ',normalize-space(@class),' '),'
level ')]/p[contains(concat(' ',normalize-space(@class),' '),' list-title ')]"
resolver:nil];
+ arxivIDNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
+
+ pdfURLNodePath = [[self domDocument]
createExpression:@"./span/a[contains(text(),'pdf')]" resolver:nil];
+ doiNodePath = [[self domDocument]
createExpression:@"../div/div/div/span[contains(text(),'doi')]/following-sibling::span/a"
resolver:nil];
+
+ titleNodePath = [[self domDocument]
createExpression:@"./p[contains(concat(' ',normalize-space(@class),' '),' title
')]" resolver:nil];
+ authorsNodePath = [[self domDocument]
createExpression:@"./p[@class='authors']/a" resolver:nil];
+ journalNodePath = [[self domDocument]
createExpression:@"./p[contains(concat(' ',normalize-space(@class),' '),'
comments ')]/span[text()='Journal ref:']/following-sibling::text()"
resolver:nil];
+ abstractNodePath = [[self domDocument]
createExpression:@"./p[contains(concat(' ',normalize-space(@class),' '),'
abstract ')]/span[contains(concat(' ',normalize-space(@class),' '),'
abstract-full ')]" resolver:nil];
+ } else if (isList) {
+ arxivLinkNodePath = [[self domDocument]
createExpression:@"./span[@class='list-identifier']" resolver:nil];
+ arxivIDNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
+
+ pdfURLNodePath = [[self domDocument]
createExpression:@"./a[contains(text(),'pdf')]" resolver:nil];
+ doiNodePath = [[self domDocument]
createExpression:@"./div[@class='list-doi']/span/following-sibling::text()"
resolver:nil];
+
+ arxivNodePath = [[self domDocument]
createExpression:@"./following-sibling::dd/div[@class='meta']" resolver:nil];
- titleNodePath = [[self domDocument]
createExpression:@"./div[contains(concat(' ',normalize-space(@class),' '),'
list-title ')]/span/following-sibling::text()" resolver:nil];
- authorsNodePath = [[self domDocument]
createExpression:@"./div[@class='list-authors']/a" resolver:nil];
- journalNodePath = [[self domDocument]
createExpression:@"./div[@class='list-journal-ref']/span/following-sibling::text()"
resolver:nil];
- abstractNodePath = [[self domDocument] createExpression:@"./p"
resolver:nil];
- } else {
- return nil;
- }
+ titleNodePath = [[self domDocument]
createExpression:@"./div[contains(concat(' ',normalize-space(@class),' '),'
list-title ')]/span/following-sibling::text()" resolver:nil];
+ authorsNodePath = [[self domDocument]
createExpression:@"./div[@class='list-authors']/a" resolver:nil];
+ journalNodePath = [[self domDocument]
createExpression:@"./div[@class='list-journal-ref']/span/following-sibling::text()"
resolver:nil];
+ abstractNodePath = [[self domDocument] createExpression:@"./p"
resolver:nil];
+ } else {
+ return nil;
}
- @catch (id e) {
- NSLog(@"Ignoring XPath exception: %@", e);
- }
AGRegex *eprintRegex1 = [AGRegex
regexWithPattern:@"([0-9]{2})([0-9]{2})\\.([0-9]{4})"
options:AGRegexMultiline];
Modified: trunk/bibdesk/BDSKIACRParser.m
===================================================================
--- trunk/bibdesk/BDSKIACRParser.m 2018-08-23 06:30:38 UTC (rev 22511)
+++ trunk/bibdesk/BDSKIACRParser.m 2018-08-23 09:55:22 UTC (rev 22512)
@@ -87,20 +87,15 @@
DOMXPathExpression *titleNodePath = nil;
DOMXPathExpression *authorNodePath = nil;
DOMXPathExpression *pathToSearchNodePath = nil;
-
- @try {
- if (isSearch) {
- titleNodePath = [[self domDocument]
createExpression:@"following-sibling::dd/b" resolver:nil];
- authorNodePath = [[self domDocument]
createExpression:@"following-sibling::dd[position()=2]/em" resolver:nil];
- pathToSearchNodePath = [[self domDocument]
createExpression:@".//a/@href" resolver:nil];
- } else {
- titleNodePath = [[self domDocument] createExpression:@".//b"
resolver:nil];
- authorNodePath = [[self domDocument] createExpression:@".//i"
resolver:nil];
- }
+
+ if (isSearch) {
+ titleNodePath = [[self domDocument]
createExpression:@"following-sibling::dd/b" resolver:nil];
+ authorNodePath = [[self domDocument]
createExpression:@"following-sibling::dd[position()=2]/em" resolver:nil];
+ pathToSearchNodePath = [[self domDocument]
createExpression:@".//a/@href" resolver:nil];
+ } else {
+ titleNodePath = [[self domDocument] createExpression:@".//b"
resolver:nil];
+ authorNodePath = [[self domDocument] createExpression:@".//i"
resolver:nil];
}
- @catch (id e) {
- NSLog(@"Ignoring XPath exception: %@", e);
- }
for (DOMNode *node in sources) {
Modified: trunk/bibdesk/DOMNode_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/DOMNode_BDSKExtensions.m 2018-08-23 06:30:38 UTC (rev
22511)
+++ trunk/bibdesk/DOMNode_BDSKExtensions.m 2018-08-23 09:55:22 UTC (rev
22512)
@@ -42,18 +42,11 @@
@implementation DOMNode (BDSKExtensions)
- (NSArray *)nodesForXPath:(NSString *)xpath {
- DOMXPathResult *result = nil;
- DOMNode *node = nil;
+ DOMXPathResult *result = [[self ownerDocument] evaluate:xpath
contextNode:self resolver:nil type:DOM_ORDERED_NODE_ITERATOR_TYPE inResult:nil];
+ DOMNode *node = [result iterateNext];
NSMutableArray *nodes = nil;
- @try {
- result = [[self ownerDocument] evaluate:xpath contextNode:self
resolver:nil type:DOM_ORDERED_NODE_ITERATOR_TYPE inResult:nil];
- }
- @catch (id e) {
- NSLog(@"Ignoring XPath exception: %@", e);
- }
-
- if ((node = [result iterateNext])) {
+ if (node) {
nodes = [NSMutableArray array];
do {
[nodes addObject:node];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit