@Test public void validFullResponse() { XmlOptions opt = (new XmlOptions()).setSavePrettyPrint(); opt.setSaveSuggestedPrefixes(Utilities.SuggestedNamespaces()); opt.setSaveNamespacesFirst(); opt.setSaveAggressiveNamespaces(); opt.setUseDefaultNamespace(); XmlObject co = completeResponse(); ArrayList errorList = new ArrayList(); boolean validXml = Utilities.validateXml(opt, co, errorList); assertTrue(errorList.toString(), validXml); }
public String AsXml() { XmlOptions opt = (new XmlOptions()).setSavePrettyPrint(); opt.setSaveSuggestedPrefixes(Utilities.SuggestedNamespaces()); opt.setSaveNamespacesFirst(); opt.setSaveAggressiveNamespaces(); opt.setUseDefaultNamespace(); DescribeSRSResponseDocument document = completeResponse(); ArrayList errorList = new ArrayList(); opt.setErrorListener(errorList); boolean isValid = document.validate(opt); // If the XML isn't valid, loop through the listener's contents, // printing contained messages. if (!isValid) { for (int i = 0; i < errorList.size(); i++) { XmlError error = (XmlError) errorList.get(i); System.out.println("\n"); System.out.println("Message: " + error.getMessage() + "\n"); System.out.println( "Location of invalid XML: " + error.getCursorLocation().xmlText() + "\n"); } } return document.xmlText(opt); }
public DescribeSRSResponseDocument completeResponse() { DescribeSRSResponseDocument document = DescribeSRSResponseDocument.Factory.newInstance(); DescribeSRSResponseType rootDoc = document.addNewDescribeSRSResponse(); rootDoc.newCursor().insertComment("Generated " + Calendar.getInstance().getTime()); ListSRSResponse.QueryInfoSrs(rootDoc.addNewQueryInfo(), "URL"); rootDoc.getQueryInfo().getQueryUrl().setName("DescribeSRS"); Utilities.addInputStringCriteria( rootDoc.getQueryInfo().addNewCriteria(), "srsName", "Mouse_ABAreference_1.0"); SRSCollection coll1 = rootDoc.addNewSRSCollection(); coll1.setHubCode("HUBA"); SRSList srsList = coll1.addNewSRSList(); SRSType srs1 = srsList.addNewSRS(); ListSRSResponse.SrsExample1(srs1); Orientations o = coll1.addNewOrientations(); OrientationType orientaiton1 = o.addNewOrientation(); // orientation(orientaiton1,code,name); ListSRSResponse.orientation(orientaiton1, "Left", "Left"); orientaiton1 = o.addNewOrientation(); ListSRSResponse.orientation(orientaiton1, "Right", "Right"); orientaiton1 = o.addNewOrientation(); ListSRSResponse.orientation(orientaiton1, "Ventral", "Ventral"); orientaiton1 = o.addNewOrientation(); ListSRSResponse.orientation(orientaiton1, "Dorsal", "Dorsal"); orientaiton1 = o.addNewOrientation(); ListSRSResponse.orientation(orientaiton1, "Posterior", "Posterior"); orientaiton1 = o.addNewOrientation(); ListSRSResponse.orientation(orientaiton1, "Anterior", "Anterior"); Slices s = rootDoc.addNewSlices(); exampleSlice(s.addNewSlice(), 1); Fiducials f = rootDoc.addNewFiducials(); exampleFiducial(f.addNewFiducial(), 1); return document; }