This repository was archived by the owner on Apr 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/com/formulasearchengine/mathmlquerygenerator
java/com/formulasearchengine/mathmlquerygenerator
resources/com/formulasearchengine/mathmlquerygenerator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,13 +112,8 @@ public static Node getMainElement( Document xml ) {
112112 return new NonWhitespaceNodeList ( expr ).item ( 0 );
113113 }
114114 // if that fails try to get content MathML from an annotation tag
115- expr = xml .getElementsByTagName ( "annotation-xml" );
116- for ( Node node : new NonWhitespaceNodeList ( expr ) ) {
117- if ( node .hasAttributes () &&
118- node .getAttributes ().getNamedItem ( "encoding" ).getNodeValue ().equals ( "MathML-Content" ) ) {
119- return node ;
120- }
121- }
115+ Node node = getContentMathMLNode (xml );
116+ if (node != null ) return node ;
122117 // if that fails too interprete content of first semantic element as content MathML
123118 expr = xml .getElementsByTagNameNS ( "*" , "semantics" );
124119 if ( expr .getLength () > 0 ) {
@@ -133,7 +128,19 @@ public static Node getMainElement( Document xml ) {
133128 return null ;
134129 }
135130
136- public String getReturnFormat () {
131+ private static Node getContentMathMLNode (Document xml ) {
132+ NodeList expr ;
133+ expr = xml .getElementsByTagName ( "annotation-xml" );
134+ for ( Node node : new NonWhitespaceNodeList ( expr ) ) {
135+ if ( node .hasAttributes () &&
136+ node .getAttributes ().getNamedItem ( "encoding" ).getNodeValue ().equals ( "MathML-Content" ) ) {
137+ return node ;
138+ }
139+ }
140+ return null ;
141+ }
142+
143+ public String getReturnFormat () {
137144 return returnFormat ;
138145 }
139146
Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ public void testCustomization() throws Exception {
105105 xQueryGenerator .setReturnFormat (testResultFormat ).setNamespace (testNamespace )
106106 .setPathToRoot (testPathToRoot );
107107 assertEquals (expectedOutput , xQueryGenerator .toString ());
108+ assertEquals (testResultFormat , xQueryGenerator .getReturnFormat ());
109+ assertEquals (testNamespace , xQueryGenerator .getNamespace ());
108110 }
109111
110112 public void testNoRestriction () throws Exception {
@@ -142,9 +144,7 @@ public void testqVarGetter() throws Exception {
142144 ArrayList <String > xPaths = firstEntry .getValue ();
143145 assertEquals ( 2 , xPaths .size () );
144146 assertEquals ( firstExpectedLocation , xPaths .get (0 ) );
145- }
146- public void testRecursion () throws Exception {
147-
147+ assertEquals (true , xQueryGenerator .isAddQvarMap ());
148148 }
149149
150150}
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <math xmlns =" http://www.w3.org/1998/Math/MathML" >
3+ <semantics >
4+ <annotation-xml encoding =" application/openmath+xml" >
5+ <OMA xmlns =" http://www.openmath.org/OpenMath" >
6+ <OMV name =" E" />
7+ </OMA >
8+ </annotation-xml >
9+ <annotation-xml encoding =" MathML-Content"
10+ id =" I1.i2.p1.1.m1.1.cmml"
11+ xref =" I1.i2.p1.1.m1.1" >
12+ <ci xml : id =" p1.1.m1.1.1.cmml" xref =" p1.1.m1.1.1" >E</ci >
13+ </annotation-xml >
14+ </semantics >
15+ </math >
Original file line number Diff line number Diff line change 1+ declare default element namespace "http://www.w3.org/1998/Math/MathML" ;
2+ for $m in db2-fn:xmlcolumn ("math.math_mathml" ) return
3+ for $x in $m//*:ci
4+ [./text () = 'E' ]
5+ where
6+ fn:count ($x/*) = 0
7+
8+ return
9+ data ($m/*[1 ]/@alttext)
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <mws : query xmlns : mws =" http://search.mathweb.org/ns" xmlns : m =" http://www.w3.org/1998/Math/MathML" limitmin =" 0"
3+ answsize =" 30" >
4+ <mws : expr >
5+ <m : apply xml : id =" p1.1.m1.1.5.cmml" xref =" p1.1.m1.1.5" >
6+ <m : plus xml : id =" p1.1.m1.1.3.cmml" xref =" p1.1.m1.1.3" />
7+ <m : apply xml : id =" p1.1.m1.1.5.1.cmml" xref =" p1.1.m1.1.5.1" >
8+ <m : csymbol cd =" ambiguous" xml : id =" p1.1.m1.1.5.1.1.cmml" >superscript</m : csymbol >
9+ <mws : qvar >x</mws : qvar >
10+ <m : cn type =" integer" xml : id =" p1.1.m1.1.2.1.cmml" xref =" p1.1.m1.1.2.1" >2</m : cn >
11+ </m : apply >
12+ <mws : qvar >x</mws : qvar >
13+ </m : apply >
14+ </mws : expr >
15+ </mws : query >
Original file line number Diff line number Diff line change 1+ declare default element namespace "http://www.w3.org/1998/Math/MathML" ;
2+ declare function local:qvarMap ($x) {
3+ map {"x" : (data ($x/*[2 ]/*[2 ]/@xml:id),data ($x/*[3 ]/@xml-id))}
4+ };
5+
6+ declare function local:compareApply ($rootApply, $depth, $x ) {
7+ (for $child in $x/* return local:compareApply (
8+ if (empty ($rootApply) and $child/name () = "apply" ) then $child else $rootApply,
9+ if (empty ($rootApply) and $child/name () = "apply" ) then 0 else $depth+1 , $child),
10+ if ($x/name () = "apply"
11+ and $x[*[1 ]/name () = 'plus' and *[2 ]/name () = 'apply' and *[2 ][*[1 ]/name () = 'csymbol' and *[1 ][./text () = 'superscript' ] and *[3 ]/name () = 'cn' and *[3 ][./text () = '2' ]]]
12+ and fn:count ($x/*[2 ]/*[1 ]/*) = 0
13+ and fn:count ($x/*[2 ]/*[3 ]/*) = 0
14+ and fn:count ($x/*[2 ]/*) = 3
15+ and fn:count ($x/*) = 3
16+ and $x/*[2 ]/*[2 ] = $x/*[3 ]
17+ ) then
18+ data ($m/*[1 ]/@alttext)
19+ else ()
20+ )};
21+
22+ for $m in db2-fn:xmlcolumn ("math.math_mathml" ) return
23+ local:compareApply ((), 0 , $m)
You can’t perform that action at this time.
0 commit comments