1
目录
一、Analysisoffunctionrequirement..............................................................................................2
1.1Introduction................................................................................................................2
1.2U...............................................................................................................................2
1.3OperatingEnvironment...............................................................................................5
1.4Theprocessofusing...............................................................................................5
二、Descriptionoftechnologyframework......................................................................................7
2.1FRAMEWORK............................................................................................................7
2.2B/SstructureandXML................................................................................................8
三、Detaileddesign..........................................................................................................................9
3.1Generalframeworkdesign(总体架构设计)................................................................9
3.2projectpicturesincludingthepackagesandclass................................................9
3.3UMLforproject,includingclassdiagram,ucaandquencediagram.............14
3.4Databadesign........................................................................................................22
3.5XMLdesign................................................................................................................25
四、Test..........................................................................................................................................28
4.1Theteststrategy.....................................................................................................28
4.2Thetestcas,includeblack-boxtesting,white-boxtestingandgray-boxtesting.
.........................................................................................................................................37
4.3Testextremedata...................................................................................................37
五、Analysisofthetoughtechnologyandfeatures.......................................................................38
5.1xml.............................................................................................................................38
5.2eXist........................................................................................................................39
5.3JavaBean................................................................................................................40
5.4Jquery........................................................................................................................40
5.5Ajax............................................................................................................................41
六、Summaryabouttheprojectandthecour...........................................................................41
七、Appendix.................................................................................................................................42
7.1CreateXMLFile........................................................................................................42
7.2SearchXML..............................................................................................................43
7.3UpdateOperate......................................................................................................48
八、References..........................................................................................................................54
2
一、Analysisoffunctionrequirement
1.1Introduction
1.1.1Thepurpoofur'smanual
Thepurpoofthisurs'manualistoenableurstoknowmoreclearlyaboutoursystem
andfacilitatetheurs’getedreadersarecommonursbutnotexperts.
1.1.2Background
Explanation:
tName:PigeonNewsPublishingSystem;
thor:haoLi
chers:JiJiaXiong,LinLeiLei,LiXueYun,ZengQi;
er:JiJiaXiong,LinLeiLei,LiXueYun,ZengQi;
1.1.3Definition
Mysql-----Open-sourceRelationaldataba
eXist-db------eXist-dbisanopensourcedatabamanagementsystembuiltusingXML
esXMLdataaccordingtotheXMLdatamodeland
featurefficient,index-badXQueryprocessing.
Xquery-----AnXMLQueryLanguage;
Xpath-------XMLPathLanguage(XMLPathLanguage),whichisanXML
documentudtodeterminethelocationofapartofthe
language
Jquery----Isacross-browrJavaScriptlibrary,andstrengthentheoperation
betweentheHTMLandJavaScript
IDE------alsoknownasintegrateddesignenvironmentorintegrateddebuggingenvironment
isasoftwareapplicationthatprovidescomprehensivefacilitiestocomputer
programmersforsoftwaredevelopment.
1.2U
1.2.1Function
a.Function:
3
a)webdeveloper:Forurstobrow,manipulate,test,theexam,courlection,
registrationaccount。
b)webprogramme:
Administrator
❖add_cour
❖update_cour
❖delete_cour
❖add_ur
❖update_ur
❖delete_ur
❖viewallurinfo
❖read_msg
❖nd_msg
❖add_msg
❖addnotice
❖viewnotice
❖changepassword
❖logout
❖Relogin
Dean
❖readExamination
❖analy_exam
❖makePaper
❖readPaper
❖viewBlank
❖read_msg
❖nd_msg
❖add_msg
❖modifypassword
❖logout
❖Relogin.
Teacher
❖makePaper
❖readExamination
❖analy_exam
❖read_msg
❖nd_msg
❖add_msg
❖modifypassword
❖logout
❖Relogin
4
Administrators
❖Managementofurinformation
❖Addurinformation.
❖Deleteurinformation.
❖Updateurinformation
❖Changepassword.
❖Returntohomepage.
❖Relogin.
b.LimitsRange:
a)webdeveloper:No;
b)webprogramme:employeecannotactbeyondtheirauthority,Cannot
arbitrarilychangetheitembankinthetitle;
1.2.2Performance
1.2.2.1Timecharacteristics
time:1-2Seconds;
singtime:1-3Seconds;
ingtime:1-3Seconds;
1.2.2.2Flexibility
ionway:
webdeveloper:Openabrowr,entertheURLvisitthewebsite;
webprogramme:Openabrowrandenterbackgroundoperation(;
ingEnvironment:
Win7/Vista/XP/Win2003
1.2.3Security
tyDesign:LoginwithPassword
entialitydesign:AnonymousLogin
webprogramme:Afterenteringtheaccountpassword,itautomatically
jumpstotheurinterface
webdeveloper:Itdoesnotdisplaytheur'sbrowsingProcess
lyreachedability:
a)LoginwithPassword;
b)Confidentialityofinformation;
5
1.3OperatingEnvironment
1.3.1Datastructure
a.Mysql:Udtostoreurs’informationforadministratorstomanage;
b.XML:UdtostoreNews;
c.eXist:Udtostore,modifyanddeleteXMLfilesfortechnicalpersonneltooperate
XML
1.4Theprocessofusing
1.4.1InstallationandInitialization
a.Installation:
webdeveloper:Installthebrowr;
webprogramme:InstallingIDE,Databa(eXist),configureJBoss;
b.Initialization:InputdatatoXMl(pageinput,thedatabainput),
initializationXML;
1.4.2Input
a.Datainput:PayattentiontotheformatwheninputtingdatatoXMl。
b.Parameterspreparation:Formaldata。
1.4.2.1Therealisticbackgroundoftheinputdata
ion:Personnelchanges,newsupdatesandchanges;
quencyofsituations:Cyclical,random;
ofsituation:WritingQuestions,updateTestquestionbank;
:keyboard;
:Inputteddatamustbeimplementedonthebasisofthewritingprovisions;
yManagement:inputteddatawillbetestedbytherelevantdepartmentsand
thebelowstandarddatawillbereturnedandrewrited;
te:DeandecidewhethertheQuestionsbankwillbeupdateandalter.
1.4.2.2OutputFormat
a.Head:ExaminationSubjects,Time,Instructor;
6
b.Body:Questions;
c.Tail:ExaminationStatusTips。
1.4.3Toexplaintheoutputofeachoutput
1.4.3.1Therealisticbackgroundoftheoutputdata
a.U:TheQuestionsPreparedbytheteacherwillbeauditbythedeanandthen
cidewhethertheyissuetheQuestionsandthe
releadoneswillbebrowedbytheurs.
b.Thefrequencyofasituation:Cyclical,Regular,random;
c.Media:Monitor;
d.QualityManagement:Relevantdepartmentsareresponsibletoexaminethenews.
Dominate:ChiefEditorshavetheownershipofthereleaandrevocationofthenews.
Urs’reactioncanindirectlydominatetheownership.
1.4.3.2OutputFormat
a.Header:ExaminationSubjects,Time,Instructor;;
b.Body:Questions;
c.Tail:ExaminationStatusTips。
1.4.4Query
a.Queryfunction:thesystemhasthefunctionofreferringtothecour-Info、teacher-Info、
ayinputanykeywordintheinquiringcolumnandthekeyword
eisnoresults,itshowsan
emptyresult,remindingtheursthatnorelevantkeywordsarefound.
b.inquirymode:
rtistobeprofessionalknowledge.
1.4.5Errorhandlingandrecovery
Erroroccurred:Thesystemerrorsaregenerallynotcaudbyurs’operation,andthe
ursmayuateast;
ErrorRecovery:Maintenancebyprofessionals;
7
1.4.6TerminalOperation
Operatingterminal:
webdeveloper:Installthebrowrandthecomputercanbeconnectedwiththe
InternetortheLocalAreaNetwork
webprogramme:operablerversthatcanbeconnectedwiththeInternetorthe
LocalAreaNetwork
二、Descriptionoftechnologyframework
2.1FRAMEWORK.
iewlayer,theroleofthestudents
cher,whocan
examinetheexaminationpapersortthepaper,nmodifyanddelete
thepaperfromallteachersorviewthemessage,heyndtherequest,
thecontrollayerwouldprocesstherequestandtaketheinformationfromtheModellayer
totheviewlayer.
图2.1.1MVCmodel
图2.1.2Scandalousdeploymentfigure
8
2.2B/SstructureandXML
Weuopensource,chooB/SstructureandXML
opensource
Inopensource,ngeXistbecauitcanbea
ver
otherhand,opensourcehasthefollowingfourdistinctadvantage:urce
technologyisaverylowcostandhasveryloworevenzerocostinexitbarriers
archanddevelopment,it
eour
sourcecodearesharedontheInternet,sonocret.
B/Sarchitecture
Inthissystem,weuB/eB/Sstructurecanbecombinedwith
chievepower
functionbeforeusingspecialandcomplexsoftwares,whichcansavealotofcostin
development.B/SbadontheWAN,whichisfordifferenturgroupsandgeographic
r,C/Sstructurecann’thatB/Sbadonthe
browr,soitcanbecross-platformbyWEBrvicesorotherpubliccanidentifythe
ybeenudinWindowplatform,but
B/SstructurecanbeudinUnix/tion,intheperformanceofthe
system,B/Sadvantageisthatanytime,anyplace,anysystem,solongascanuthe
browrontheInternet,youcanutheB/s,mostC/S
structureofsoftwarearedirectlyconnectedtothedatabathroughODBC,whichwould
eeachurwillbeconnectedto
thedatabatomaintainaODBCconnection,soresourceshavebeenoccupiedallthe
ontrary,allursareusingaJDBC
connectionpooltoconnecttothedatabaintheB/,theurdoesnot
maintainaconnectiontothedatabaandsubscribersbasicallyislimitless.
UsingXMLtostorethenewsinformation
edwith
otherdataformats,amajoradvantageofXMListhatitisverysimilartotheobjectdata
hemostofcurrentprogramdesignanddevelopmentisobject-oriented,
sousingXMLtoexpressiondatathatcanenabledataprocessinganddisminationhas
y,XMLformatisversatility,convenient,andhighefficiency,
ly,XMLhastheadvantageofkeepingthe
document,whichstoringdata,,thedatabeextracted
atacanbeudorcalledina
tion,weknowthatXMLixtensiblemarkuplanguage,so,
ingdatainXML,youcanlargely
toneisthatXMLbrokeallkindsoffortresson
networks,whichleadtovalueofthedatacanflowandexchangebetweenthem,andto
achievethebusinesspurposofsharinginformation.
9
三、Detaileddesign
3.1Generalframeworkdesign(总体架构设计)
3.1.1TheGeneralprinciplesofdesignforthesystem
fication(简单化)
Thesystemshouldbeeasytouwhenmeettherequirementandreach
thegoalofexpectation.
ility(灵活性)
ThesystemshouldadapttothechangesoftheEnvironment.
ility(可靠性)
Thesystemshouldhaveahighreliability.
3.2projectpicturesincludingthepackagesandclass.
Picture3.2.1thejavacodeofeXistdateba
10
Picture3.2.2thejavacodeofroles
Picture3.2.3allthefilesoftheadmin
11
Picture3.2.4allthefilesofthedean
12
Picture3.2.5allthefilesofthestudent
Picture3.2.6allthefilesoftheteacher
13
Picture3.2.7allthefilesofthecss
Picture3.2.8allthefilesofthejar
14
Picture3.2.9allthefilesofthejs
3.3UMLforproject,includingclassdiagram,ucaand
quencediagram.
Picture3.3.1quencediagramoflogin
15
Picture3.3.2quencediagramofstudenttakeexam
Picture3.3.3quencediagramofteachermakequestion
16
Picture3.3.4quencediagramofstudentcheckscores
Picture3.3.5quencediagramofteacherReviewpapers
17
Picture3.3.6classdiagramofteacher
Picture3.3.7classdiagramofdean
18
Picture3.3.8classdiagramofstudent
Picture3.3.9classdiagramofadmin
19
Picture3.3.10classdiagramofteacher
Picture3.3.11classdiagramofthepaper
20
Picture3.3.11classdiagramofthestudent
Picture3.3.12classdiagramofthequestionbank.
21
Picture3.3.12classdiagramoftheadmin.
Picture3.3.13classdiagramoftheupdateoperationfortheeXist.
22
Picture3.3.14classdiagramoftheSearchxmlfiles.
Picture3.3.14classdiagramoftheCreatexmlfiles.
3.4Databadesign.
heobject-orienteddataba–eXisttostoreandmanagethexml
sanopensourcedatabamanagementsystementirelybuiltonXML
technology,mostrelationaldataba
managementsystems,eXistusXQuery,whichisaW3CRecommendation,to
manipulateitsdata.
23
Picture3.4.1TheflowofOODB-Existprocessingdata
Picture3.4.2eXistXqueryStatement
24
Picture3.4.3eXiststoreXMLfiles
Picture3.4.4eXiststoreXMLfiles
25
3.5XMLdesign
Picture3.5.1theXMLfilesoftheadmin
Picture3.5.2theXMLfilesofthecour
26
Picture3.5.3theXMLfilesofthequestionsBlank
Picture3.5.4theXMLfilesofthestudent
27
Picture3.5.5theXMLfilesoftheteacher
Picture3.5.6theXMLfilesofthestudentexam
28
四、Test
4.1Theteststrategy
(Wechootheblack-boxtestingmethodtotestthesystem.)
4.1.1Introduce
onfirm
eachfunctionhavebeenfinishednormallyornotbytheblack-boxtestingmethod.
Intesting,theprogramasacannotopentheblackbox,whilenotconsideringthe
internalstructureandinternalcharacteristicscompletely,testerstesttheprogrambythe
programminginterfaces.
Blackboxtestingonlycheckwhethertheprogram’sfunctionscanunormally
accordingtotheproductrequirementspecificationandtheprogramcanprintaright
resultwhentheurshaveaappropriateinputornot,andkeeptheintegrityofexternal
information(suchasdatabaordocuments).
4.1.2Testdesigntechniques
Typicalblack-boxtestdesigntechniquesinclude:
•Decisiontabletesting.
•All-pairstesting.
•Statetransitiontables.
•Equivalencepartitioning.
•Boundaryvalueanalysis.
4.1.3Whatisblack-boxtesting.
Black-boxtestingismainlytofoundthefollowingcategorierrors:
rtherebeincorrectoromissionsfunctions?
nterfaces,canacceptinputcorrectlyorCanoutputthecorrectresult?
rthereisadatastructureerrorsorexternalinformation(forexampledatafiles)
errors?
rtheperformancecanmeettherequirements?
rhaveinitializationorterminatemistake?
29
4.1.4Functionstesting.
Onlytestingthefunctionsofadiminandteacher.
4.1.4.1Administror’sfunctiontesting:
Picture4.1.4.1Loginmodeltesting
Picture4.1.4.2adminmodelindex
30
Picture4.1.4.2adminaddateacher
Picture4.1.4.3adminaddacour
Picture4.1.4.4adminaddanotice
31
Picture4.1.4.5adminviewthenotice
Picture4.1.4.6adminaddadean
Picture4.1.4.7adminupdatetheur’sinformation
32
Picture4.1.4.8admindeletetheur’sinformation
Picture4.1.4.9adminviewtheurs’information
Picture4.1.4.10adminupdatethecour’sinformation
33
Picture4.1.4.11admindeletethecour’sinformation
Picture4.1.4.12adminaddamessagetothedean
Picture4.1.4.13adminviewthemessagetotheteacher
Picture4.1.4.13adminviewthemessagetothehim
34
Picture4.1.4.13adminchangepassword
4.1.4.2Teachers’functiontesting:
Picture4.1.4.2.1teacherindex
Picture4.1.4.2.2teachermakesinglequestions
35
Picture4.1.4.2.3teachermakeJudgequestions
Picture4.1.4.2.4teachermakeSubjectivequestions
Picture4.1.4.2.5therecordsofteachermakingquestions
Picture4.1.4.2.6teacherreviewingpapers
36
Picture4.1.4.2.7teacherAnalyzingpapers
Picture4.1.4.2.8teacherwritinganotice
Picture4.1.4.2.9theoutboxesofteacher
Picture4.1.4.2.10theinboxofteacher
37
Picture4.1.4.2.11teacherchangepassword
4.2Thetestcas,includeblack-boxtesting,white-box
testingandgray-boxtesting.
Testcasareatoftestinputs,executeconditionsandtheexpectedresults
designedforaspecificpurpoofTotestextremedata,anditistheminimumentity
executed.
Hereisatestcaforloginfunctionmodel:
4.3Testextremedata
Boundaryvalueanalysis(BVA)isablackboxtestingmethodudtotesttheboundary
valuesofinputoroutput.
theboundaryvaluetestprinciple
1)iftheinputconditionsstipulatedthemaximumnumberofmaximalnumberisud,
theminimumnumber,thenumberofsmallathanthesmallestnumber,thanthelargest
numberfreshmannumberastestdata.
2)iftheinputconditionsstipulatedthevalueofscope,itshouldbetakenjustreached
thisrangeboundariesvaluesandjustbeyondthisboundaryvalueasatestinputdata.
3)iftheprogramwasudinaninternaldatastructure,shouldchootheinternal
datastructuresoftheboundaryvalueastestcas.
4)iftheprogramspecificationgiveninputfieldsoroutputdomainisorderedt,should
belectedtthefirstelementandthelastelementastestcas.
5)analysisprogramspecification,andfindouttheotherpossibleboundaryconditions.
monboundaryvalue
1)screencursorintheupperleft,mostlowerposition.
2)arrayelementofthefirstandthelastone.
3)Thefirstlineandthelastlineofstatements.
38
4)The0times,thefirsttime,reciprocalcondandfinalofloop.
五、Analysisofthetoughtechnologyand
features
5.1xml
TechnologyTechnology
descriptions
Content
XML
HistoryTheversatilityofSGMLfordynamicinformation
displaywasunderstoodbyearlydigitalmediapublishersinthe
id-1990s
somepractitionersofSGMLhadgainedexperiencewiththe
then-newWorldWideWeb,andbelievedthatSGMLoffered
solutionstosomeoftheproblemstheWebwaslikelytofaceas
nollyaddedSGMLtothelistofW3C'sactivities
whenhejoinedthestaffin1995;workbeganinmid-1996when
SunMicrosystemngineerJonBosakdevelopedacharterand
aswellconnectedinthesmall
communityofpeoplewhohadexperiencebothinSGMLandthe
Web.
Key
terminology
.(Unicode)Character
.rocessorandApplication
.MarkupandContent
.Tag
.Element
.Attribute
.XMLDeclaration
Characters
andescaping
.Validcharacters
.Encodingdetection
.Escaping
.Comments
.Internationalu
39
5.2eXist
TechnologyTechnology
descriptions
Content
eXist
introduceeXistisanopensourcedataba
managementsystementirelybuiltonXML
technology,alsocalledanativeXML
mostrelationaldataba
managementsystems,eXistusXQuery,
whichisaW3CRecommendation,to
manipulateitsdata.
eXistBenefitXistallowssoftwaredeveloperstopersist
XMLdatawithoutwritingextensive
ollowsandextends
manyW3CXMLstandardssuchasXQuery.
eXistalsosupportsRESTinterfacesfor
interfacingwithAJAX-typewebforms.
ApplicationssuchasXFormsmaysave
theirdatabyusingjustafewlinesofcode.
TheWebDAVinterfacetoeXistallowsurs
to"draganddrop"XMLfilesdirectlyintothe
eeXist
automaticallyindexesdocumentsusinga
keywordindexingsystemitisveryeasyto
createhigh-performancedocumentarch
systemswitheXist.
eXistStandards
andTechnologies
eXisthassupportforthefollowing
standardsandtechnologies
XPath-XMLPathlanguage
XQuery-XMLQuerylanguage
WebDAV-Webdistributedauthoringand
versioning
REST-Reprentationalstatetransfer
(URLencoding)
SOAP-SimpleObjectAccessProtocol
XACML-XMLAccessControlLanguage
XInclude-rver-sideincludefileprocessing
(limitedsupport)
XML-RPC-aremoteprocedurecall
protocol
XProc-aXMLPipelineprocessing
language
40
5.3JavaBean
TechnologyTechnology
descriptions
Content
JavaBean
IntroduceJavaBeansarereusablesoftwarecomponents
forJavathatcanbemanipulatedvisuallyina
cally,theyareclasswritten
intheJavaprogramminglanguageconforming
eudto
encapsulatemanyobjectsintoasingleobject
(thebean),sothattheycanbepasdaroundas
asinglebeanobjectinsteadofasmultiple
eanisaJavaObject
thatisrializable,hasanullaryconstructor,
andallowsaccesstopropertiesusinggetterand
ttermethods
JavaBean
conventions
Therequiredconventionsare:
Theclassmusthaveapublicdefaultconstructor
(no-argument).Thisallowasyinstantiation
withineditingandactivationframeworks.
Theclasspropertiesmustbeaccessibleusing
get,t,is(udforbooleanpropertiesinstead
ofget)andothermethods(so-calledaccessor
methodsandmutatormethods),followinga
lowasy
automated
inspectionandupdatingofbeanstatewithin
frameworks,manyofwhichincludecustom
editorsforvarioustypesofproperties.
lows
applicationsandframeworkstoreliablysave,
store,andrestorethebean'sstateinafashion
independentoftheVMandoftheplatform.
5.4Jquery
TechnologyTechnology
descriptions
Content
IntroduceJqueryisaexcellentframeworkoftheJavascript
41
Jquery
uuJquery,youwould
who
usuchaparabletocompareprototypeand
jquery:PrototypeasJava,whilejquerylikeruby.
featureComparedtoJavascript,Jqueryismoresimple
emanyfunctionsarealready
feeldifficult,becauthe
r,as
longasweoperatingskilled,wewouldlikeit.
5.5Ajax
TechnologyTechnology
descriptions
Content
Ajax
Introduce
AJAXis“AsynchronousJavaScriptandXML”.This
the
clientscriptsntanHTTPrequest(XMLHTTP)
thatthefirstcomponentbyOutlookWebAccess
mponentoriginallyowned
byMicrosoftExchangeServer,andquickly
becamepartofInternetExplorer4.0.
feature1:AJAXprospectveryoptimistic,itcanimprove
systemperformance,optimizetheurinterface
2:AJAXdevelopersmustunderstandthe
traditionalMVCframework,whichlimitingthe
boundariesbetweenapplicationlevels.
六、Summaryabouttheprojectandthe
cour
AboutXMLandthenewsreleasystem,Ihaven'ttouchedbeforeandherearesome
feelingaboutthem.
Feelingforxml:
XMLisExtensibleMarkupLanguage,anditissametotheHTML,alltheyareStandard
GeneralizedLanguage(SGMLcreating,StandardgeneralMarkupLanguage).Xmlisa
technologythatcross-platformanddependingonthecontentintheInternetenvironment,
anditis
addition,XMLisasimpledatastoragelanguage,usingariesofsimplemarksto
42
ghit
covermorespacethanthebinarydata,butitiasytograspanduextremelysimple.
hiscourandxml,aboutxml,itwillbeud
moreandmoreinthefurture.
WiththedevelopmentoftheInternet,networkmediastatushaveimprovedinpeople's
heart,andnewsreleasystemasthecoresysteminthenetworkmedia,itismoreand
nehand,itprovidesafunctionthatmanageandreleanews
andOntheotherhand,nowthenewsreleasystemallowtointeractwiththeordinary
urs,andurscaneasilytoattendsomeinvestigationandrelatednewscomment,
that'ayaslongasyouonthe
Internet,ationpapersgenerator
willbeudmoreandmorewiththedevelopmentoftheinternet.
七、Appendix
7.1CreateXMLFile
packageeXist;
Keys;
Service;
Manager;
tion;
ceSet;
ce;
xception;
ceIterator;
;
ource;
eQueryService;
;
List;
;
publicclassCreateXMLFile{
staticStringURL="xmldb:exist://localhost:8080/exist/xmlrpc/db/examination";
//Stringdriver="Impl";
publicstaticvoidcreateStudentRoot(StringxmlName){
execute(xmlName,"
}
publicstaticvoidcreateCourRoot(StringxmlName){
execute(xmlName,"
43
}
publicstaticvoidcreateBlankRoot(StringxmlName){
execute(xmlName,"
}
publicstaticvoidcreateTeacherRoot(StringxmlName){
execute(xmlName,"
}
publicstaticvoidcreateExamRoot(StringxmlName){
execute(xmlName,"
}
publicstaticvoidcreateAdminRoot(StringxmlName){
execute(xmlName,"
}
privatestaticvoidexecute(Stringxmlname,StringtypeNode){
try{
Classcl=e("Impl");
Databadataba=(Databa)tance();
perty("create-databa","true");
erDataba(databa);
Collectioncol=lection(URL,"admin","");
XMLResourceres=(XMLResource)Resource(xmlname,"XMLResource");
tent(typeNode);
esource(res);
}catch(ClassNotFoundExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(InstantiationExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(IllegalAccessExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(XMLDBExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}
}
}
7.2SearchXML
packageeXist;
.*;
44
ute;
nt;
ntException;
ntHelper;
t;
;
der;
Service;
Manager;
tion;
;
ceIterator;
ceSet;
xception;
publicclassSearchXML{
privateCollectioncollection;
privateStringxmlName;
privateResourceSetresultSet;
privateStringXQUERY_1;
privateString[]blank;
privateMap
publicResourceSetgetResultSet(){
returnresultSet;
}
//获取结果集
publicvoidtResultSet(ResourceSetresultSet){
Set=resultSet;
}
//对获取到的值经过处理后才返回
publicArrayList
collectionToService();
XQueryServicervice;
ArrayList
try{
rvice=(XQueryService)vice("XQueryService",
"1.0");
Set=(xquery);
//n(resultSet.);
//遍历结果集并对查到的结果进行整理,且是把每一条新闻的信息放到一个Map类中
for(ResourceIteratori=rator();
eResources();){
45
Stringstr=(String)source().getContent();
//n(str);
map=newHashMap();
//SAXReaderreader=newSAXReader();
Documentdocument=ext(str);
(tElement().getName(),
tElement().getText());
Listlist1=((Element)tElement()).attributes();
if(()>0){
for(intj=0;j<();j++){
Attributeattr=(Attribute)(j);
if(attr!=null)
(e(),ue());
}
}
treeWalk(tElement());
(map);//把Map类放到数组中
}
returnlist;
}catch(XMLDBExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(DocumentExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}
returnlist;
}
//直接取得要求的值
publicArrayList
collectionToService();
XQueryServicervice;
ArrayList
try{
rvice=(XQueryService)vice("XQueryService",
"1.0");
Set=(xquery);
//n(resultSet.);
//遍历结果集并对查到的结果进行整理,且是把每一条新闻的信息放到一个Map类中
for(ResourceIteratori=rator();
eResources();){
Stringstr=(String)source().getContent();
//n(str);
46
map=newHashMap();
//SAXReaderreader=newSAXReader();
Documentdocument=ext(str);
(tElement().getName(),str);
(map);//把Map类放到数组中
}
returnlist;
}catch(XMLDBExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(DocumentExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}
returnlist;
}
publicintdoQuery1(Stringxquery){
//n(condition);
collectionToService();
XQueryServicervice;
try{
rvice=(XQueryService)vice("XQueryService",
"1.0");
Set=(xquery);
//n(resultSet);
if(!rator().hasMoreResources())
return0;
String
tem=(String)rator().nextResource().getContent();
if(tem=="")
return0;
intnum=nt(tem);
returnnum;
}catch(XMLDBExceptione){
//TODOAuto-generatedcatchblock
return0;
}
}
privatevoidtreeWalk(Elementelement){
//TODOAuto-generatedmethodstub
for(inti=0;i
Nodenode=(i);
if(nodeinstanceofElement){
47
Stringstr=t();
//str=eAll("","");
//str=eAll("n","");
(e(),str);
//获取属性的值
Listlist=((Element)node).attributes();
if(()>0){
for(intj=0;j<();j++){
Attributeattr=(Attribute)(j);
if(attr!=null)
(e(),ue());
}
}
treeWalk((Element)node);
}
}
}
publicvoidcollectionToService(){
String
URL="xmldb:exist://localhost:8080/exist/xmlrpc/db/examination";
try{
Classcl=e("Impl");
Databadataba=(Databa)tance();
erDataba(databa);
collection=(Collection)
lection(URL,"admin","");
}catch(ClassNotFoundExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(InstantiationExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(IllegalAccessExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(XMLDBExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}
}
}
48
7.3UpdateOperate
packageeXist;
Manager;
tion;
;
xception;
s.*;
publicclassUpdateOperate{
privateCollectioncollection;
publicUpdateOperate(){
//连接到服务器
collectionToService();
}
//在指定的节点后插入名为elementName的新的节点
publicvoidinrtAfter(Stringlocation,StringelementName,Stringvalue){
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
"
value+
""+
""+
"";
saveUpdate(xupd);
}
//对指定的节点进行值的更新
publicvoidupdate(Stringlocation,Stringvalue){
//n(location);
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
lect='"+location+"'>"+value+""+"";
//n("
lect='"+location+"'>"+value+""+"");
saveUpdate(xupd);
}
//在指定的节点内添加名为elementName的子节点
publicvoidappend(Stringlocation,StringelementName,Stringvalue){
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
49
"
value+
""+
""+
"";
saveUpdate(xupd);
}
publicvoidappend(Stringlocation,Stringelement){
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
element+
""+
"";
//n("
lect='"+location+"'>"+element+"");
saveUpdate(xupd);
}
//对指定节点重命名
publicvoidreName(Stringlocation,Stringvalue){
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
lect='"+location+"'>"+value+""+"";
saveUpdate(xupd);
}
//在指定的节点前添加一个名为elementName的节点
publicvoidinrtBefore(Stringlocation,StringelementName,Stringvalue){
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
"
value+
""+
""+
"";
saveUpdate(xupd);
}
//完整的添加题库的节点
publicvoidaddBlankNode(Stringc_id){
SearchXMLarch=newSearchXML();
Stringxquery="for$xindoc("")/exam_blank/cour[@c_id=""+c_id+""]return
50
count($x)";
intcount=y1(xquery);
if(count>0){
("题库已存在此课程!不能重复添加!");
return;
}
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
+"
"
"
"
""+
""+
"";
saveUpdate(xupd);
}
publicbooleanaddTeacherNode(StringteaId){
SearchXMLarch=newSearchXML();
Stringxquery="for$xindoc("")/teachers/teacher[@teaId=""+teaId+""]return
count($x)";
intcount=y1(xquery);
if(count>0){
("职工号已存在!不能重复添加!");
returnfal;
}
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
+"
"
"
"
"
"
"
"
"
"
"
"
""+
""+
51
"";
saveUpdate(xupd);
returntrue;
}
publicbooleanaddStudentNode(StringstuId){
SearchXMLarch=newSearchXML();
Stringxquery="for$xindoc("")/students/student[@stuId=""+stuId+""]return
count($x)";
intcount=y1(xquery);
if(count>0){
("学号已存在!不能重复添加!");
returnfal;
}
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
+"
"
"
"
"
"
"
"
"
"
"
""+
""+
"";
saveUpdate(xupd);
returntrue;
}
publicbooleanaddCourNode(Stringc_id){
SearchXMLarch=newSearchXML();
Stringxquery="for$xindoc("")/cours/cour[@c_id=""+c_id+""]return
count($x)";
intcount=y1(xquery);
if(count>0){
("此课程号已存在!不能重复添加!");
returnfal;
}
Stringxupd="
xmlns:xupdate='/xupdate'>"+
52
"
+"
"
"
"
"
"
""+
""+
"";
saveUpdate(xupd);
returntrue;
}
publicvoidaddAdminNode(){
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
"
"
"
""+
"";
saveUpdate(xupd);
}
publicvoidaddStudentExamNode(StringstuId,Stringc_id){
SearchXMLarch=newSearchXML();
StringSQUERY_1="for$xin
doc("")/exam/student[@stuId=""+stuId+""]/cour[@c_id=""+c_id+""]return
count($x)";
if(y1(SQUERY_1)>0){
n("试卷生成失败,原因是之前有生成");
return;
}
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
+"
"
"
"
"
"
"
"
53
"
"
""+
"
"
"
""+
""+
""+
"";
saveUpdate(xupd);
}
//移除指定的节点
publicvoidremoveElement(Stringlocation){
//n("removeElement="+location);
Stringxupd="
xmlns:xupdate='/xupdate'>"+
"
saveUpdate(xupd);
}
//对改变后的数据进行更新
privatevoidsaveUpdate(Stringxupd){
try{
XUpdateQueryServicervice=
(XUpdateQueryService)vice("XUpdateQueryService","1.0");
(xupd);
}catch(XMLDBExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}
}
publicvoidcollectionToService(){
StringURL="xmldb:exist://localhost:8080/exist/xmlrpc/db/examination";
try{
Classcl=e("Impl");
Databadataba=(Databa)tance();
erDataba(databa);
collection=(Collection)lection(URL,"admin","");
}catch(ClassNotFoundExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(InstantiationExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
54
}catch(IllegalAccessExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}catch(XMLDBExceptione){
//TODOAuto-generatedcatchblock
tackTrace();
}
}
}
八、References
[1].n·······BrettMcLaughlinPublisher:O’Reilly。
[2].JSP网站开发详解··········唐友国Publisher:电子工业大学出版社。
[3].JSP动态网站开发··········张银鹤Publisher:清华大学出版社。
[4].XML实践教程············张银鹤Publisher:清华大学出版社。
[5].Adobe数字艺术中心PSCS标准教材·Adobe公司北京代表处Publisher:人民邮
电出版社。
[6]eXist详解·············(网上教程)。
[7].CSS网页设计标准教程········温谦Publisher:人民邮电出版社。
[8].JSP动态网站开发案例指导······余芳Publisher:电子工业大学出版社。
[9].Web2.0动态网站开发—JSP技术详解与应有实
践················唐爱国Publisher:清华大学出版社。
本文发布于:2023-01-04 05:21:40,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/90/88843.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |