Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 801e405

Browse files
committed
Add semantics element as option for a CMML representaiton
Change-Id: I937a973585ff978df1653126dd4691f3ac4835ce
1 parent 5ed3ac9 commit 801e405

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ XQuery statements in DB2 dialect.
77
The content MathML elements may be given as
88

99
1. [MathWebSearch](http://search.mathweb.org/) expressions,
10-
2. annotation-xml elements with the attribute ```encoding="MathML-Content"``` or
11-
3. MathML tags that contain content MathML only
10+
2. annotation-xml elements with the attribute ```encoding="MathML-Content"```,
11+
3. semantic elements, or
12+
4. MathML tags that contain content MathML only
1213

1314
##Details
1415

1516
If a document contains multiple elements, only the first MathWebSearch expression is processed.
1617

1718
If no MathWebSearch element is available, the first annotation-xml element will be used.
1819

19-
If no annotation-xml Math element is available, the first math element will be used.
20+
If no annotation-xml Math element is available, the first semantic element will be used.
21+
22+
...

src/main/java/de/tuberlin/dima/schubotz/mathmlquerygenerator/XQueryGenerator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ public static Node getMainElement (Document xml) {
6565
return node;
6666
}
6767
}
68+
// if that fails too interprete content of first semantic element as content MathML
69+
expr = xml.getElementsByTagName( "semantics" );
70+
if ( expr.getLength() > 0 ) {
71+
return new NdLst( expr ).item( 0 );
72+
}
6873
// if that fails too interprete content of root MathML element as content MathML
6974
expr = xml.getElementsByTagName( "math" );
7075
if ( expr.getLength() > 0 ) {
7176
return new NdLst( expr ).item( 0 );
7277
}
78+
7379
return null;
7480
}
7581

@@ -158,7 +164,7 @@ private String generateConstraint (Node node, boolean isRoot) {
158164
}
159165

160166
} else if ( child.getNodeType() == Node.TEXT_NODE ) {
161-
out = "./text() = '" + child.getNodeValue() + "'";
167+
out = "./text() = '" + child.getNodeValue().trim() + "'";
162168
}
163169
}
164170
}

0 commit comments

Comments
 (0)