Created
June 12, 2015 12:30
-
-
Save lsharada/a8725bcd70e804b4ff6e to your computer and use it in GitHub Desktop.
reverse engineer an xquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steps | |
1.Create a simple java program that either call or embed an xquery | |
2.Input the java program into Altova UML/any open source available for java for creating sequence diagram | |
import javax.xml.xquery.*; | |
import net.cfoster.sedna.xqj.SednaXQDataSource; | |
public class SimpleQuery | |
{ | |
/** | |
* | |
* @param symbol | |
*/ | |
public double GetBookPrice (String symbol) throws XQException, XQException | |
{ | |
XQDataSource xqs = new SednaXQDataSource(); | |
xqs.setProperty("serverName", "localhost"); | |
xqs.setProperty("databaseName", "test"); | |
XQConnection conn = xqs.getConnection("SYSTEM", "MANAGER"); | |
XQExpression xqe = conn.createExpression(); | |
String xqueryString = | |
"for $x in doc('books.xml')//book return $x/title/text()"; | |
XQResultSequence rs = xqe.executeQuery(xqueryString); | |
while(rs.next()) | |
System.out.println(rs.getItemAsString(null)); | |
conn.close(); | |
} | |
/** | |
* | |
* @param symbol | |
*/ | |
public double GetBookDetails (String symbol) throws XQException, XQException | |
{ | |
XQDataSource xqs = new SednaXQDataSource(); | |
xqs.setProperty("serverName", "localhost"); | |
xqs.setProperty("databaseName", "test"); | |
XQConnection conn = xqs.getConnection("SYSTEM", "MANAGER"); | |
XQExpression xqe = conn.createExpression(); | |
String xqueryString = | |
"for $x in doc('books.xml')//book return $x/title/text()"; | |
XQResultSequence rs = xqe.executeQuery(xqueryString); | |
while(rs.next()) | |
System.out.println(rs.getItemAsString(null)); | |
conn.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment