update FML parsers to accept R5 metadata in R4 FML format

This commit is contained in:
Grahame Grieve 2024-03-27 21:14:00 +11:00
parent 51380bad07
commit c9490d88d1
2 changed files with 31 additions and 33 deletions

View File

@ -76,14 +76,13 @@ public class FmlParser extends ParserBase {
if (lexer.hasComments()) {
result.makeElement("description").markLocation(lexer.getCurrentLocation()).setValue(lexer.getAllComments());
}
} else {
while (lexer.hasToken("///")) {
lexer.next();
String fid = lexer.takeDottedToken();
Element e = result.makeElement(fid).markLocation(lexer.getCurrentLocation());
lexer.token("=");
e.setValue(lexer.readConstant("meta value"));
}
}
while (lexer.hasToken("///")) {
lexer.next();
String fid = lexer.takeDottedToken();
Element e = result.makeElement(fid).markLocation(lexer.getCurrentLocation());
lexer.token("=");
e.setValue(lexer.readConstant("meta value"));
}
lexer.setMetadataFormat(false);
if (!result.hasChild("status")) {

View File

@ -640,31 +640,30 @@ public class StructureMapUtilities {
result.setName(lexer.readConstant("name"));
result.setDescription(lexer.getAllComments());
result.setStatus(PublicationStatus.DRAFT);
} else {
while (lexer.hasToken("///")) {
lexer.next();
String fid = lexer.takeDottedToken();
lexer.token("=");
switch (fid) {
case "url" :
result.setUrl(lexer.readConstant("url"));
break;
case "name" :
result.setName(lexer.readConstant("name"));
break;
case "title" :
result.setTitle(lexer.readConstant("title"));
break;
case "description" :
result.setTitle(lexer.readConstant("description"));
break;
case "status" :
result.setStatus(PublicationStatus.fromCode(lexer.readConstant("status")));
break;
default:
lexer.readConstant("nothing");
// nothing
}
}
while (lexer.hasToken("///")) {
lexer.next();
String fid = lexer.takeDottedToken();
lexer.token("=");
switch (fid) {
case "url" :
result.setUrl(lexer.readConstant("url"));
break;
case "name" :
result.setName(lexer.readConstant("name"));
break;
case "title" :
result.setTitle(lexer.readConstant("title"));
break;
case "description" :
result.setTitle(lexer.readConstant("description"));
break;
case "status" :
result.setStatus(PublicationStatus.fromCode(lexer.readConstant("status")));
break;
default:
lexer.readConstant("nothing");
// nothing
}
}
if (!result.hasId() && result.hasName()) {