我有一些看起来像这样的xml文件:
if ($scope.IsDinamicReport) {
$http({
method: "POST",
url: "/api/DynamicReport/Post?pageNumber=" + $scope.PageNum + "&orderbyColumn=" + $scope.orderByColumn + "&sortOrder=" + $scope.sortOrder
+ "&showNumberPagingStats=" + $scope.showNumberPagingStats,
contentType: "application/json",
data: $scope.report
}).then(function (result) {
angular.copy(result, $scope.dynamicReport);
if (!$scope.dynamicReport.Error) {
$scope.HideDynamicRepFunctions = false;
$scope.exportColumnSelected = $scope.dynamicReport.Columns[0]; //Set default for export drop down
//TABLE SIZING
var persentage = $scope.returnTableSizing(result.Columns.length);
$('[data-table=container]')
.css('margin-left', '25px')
.css('padding-right', '25px')
.css('width', persentage)
.css('max-width', persentage);
}
else
alert("Error occured while generating the report, please contact helpdesk.");
}).catch(function (data) {
alert("An error occured while generating the report, please try again.");
});
}
如何使用<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.0" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
<xmi:Documentation exporter="StarUML" exporterVersion="2.0"/>
<uml:Model xmi:id="AAAAAAFareTxvby24dA=" xmi:type="uml:Model" name="RootModel">
<packagedElement xmi:id="AAAAAAFF+qBWK6M3Z8Y=" name="Model" visibility="public" xmi:type="uml:Model">
<packagedElement xmi:id="AAAAAAFardVTNLu3sj8=" name="Collaboration1" visibility="public" isAbstract="false" isFinalSpecialization="false" isLeaf="false" xmi:type="uml:Collaboration">
<ownedMember xmi:id="AAAAAAFardVTNLu4D8A=" name="Interaction1" visibility="public" isReentrant="true" xmi:type="uml:Interaction">
<lifeline xmi:id="AAAAAAFarde+1LvKN6g=" name="Lifeline1" visibility="public" xmi:type="uml:Lifeline" represents="AAAAAAFarde+1LvJ564="/>
<lifeline xmi:id="AAAAAAFardf7yrvsb8c=" name="MenuUI" visibility="public" xmi:type="uml:Lifeline" represents="AAAAAAFardf7yrvrcg8=">
<xmi:Extension extender="StarUML">
<stereotype value="boundary"/>
</xmi:Extension>
</lifeline>
<lifeline xmi:id="AAAAAAFardxJILwRIg4=" name="Lifeline2" visibility="public" xmi:type="uml:Lifeline" represents="AAAAAAFardxJILwQ1Co=">
<xmi:Extension extender="StarUML">
<stereotype value="Control"/>
</xmi:Extension>
</lifeline>
<lifeline xmi:id="AAAAAAFard3TVLwzblk=" name="JASP Database" visibility="public" xmi:type="uml:Lifeline" represents="AAAAAAFard3TVLwyteg=">
<xmi:Extension extender="StarUML">
<stereotype value="entity"/>
</xmi:Extension>
</lifeline>
<message xmi:id="AAAAAAFareGVNLxXGek=" name="showJASPForm" visibility="public" xmi:type="uml:Message" messageSort="synchCall" messageKind="complete" receiveEvent="AAAAAAFareTxvby4sh8=" sendEvent="AAAAAAFareTxvby3aMk="/>
<message xmi:id="AAAAAAFareJipLxuCJI=" name="CreateForm" visibility="public" xmi:type="uml:Message" messageSort="synchCall" messageKind="complete" receiveEvent="AAAAAAFareTxvby6G+A=" sendEvent="AAAAAAFareTxvby5M/Y="/>
<message xmi:id="AAAAAAFareMNVryH/kg=" name="InsertForm" visibility="public" xmi:type="uml:Message" messageSort="synchCall" messageKind="complete" receiveEvent="AAAAAAFareTxvby89AI=" sendEvent="AAAAAAFareTxvby7vl0="/>
<message xmi:id="AAAAAAFareM+ArydC68=" name="ShowSucces" visibility="public" xmi:type="uml:Message" messageSort="reply" messageKind="complete" receiveEvent="AAAAAAFareTxvby+fr4=" sendEvent="AAAAAAFareTxvby9N9U="/>
<fragment xmi:id="AAAAAAFareTxvby3aMk=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFarde+1LvKN6g="/>
<fragment xmi:id="AAAAAAFareTxvby4sh8=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFardf7yrvsb8c="/>
<fragment xmi:id="AAAAAAFareTxvby5M/Y=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFardf7yrvsb8c="/>
<fragment xmi:id="AAAAAAFareTxvby6G+A=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFardxJILwRIg4="/>
<fragment xmi:id="AAAAAAFareTxvby7vl0=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFardxJILwRIg4="/>
<fragment xmi:id="AAAAAAFareTxvby89AI=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFard3TVLwzblk="/>
<fragment xmi:id="AAAAAAFareTxvby9N9U=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFard3TVLwzblk="/>
<fragment xmi:id="AAAAAAFareTxvby+fr4=" xmi:type="uml:OccurrenceSpecification" covered="AAAAAAFarde+1LvKN6g="/>
</ownedMember>
<ownedAttribute xmi:id="AAAAAAFarde+1LvJ564=" name="Role1" visibility="public" isStatic="false" isLeaf="false" type="AAAAAAFardeb5LvGhG0=" isReadOnly="false" isOrdered="false" isUnique="false" xmi:type="uml:Property" aggregation="none" isDerived="false" isID="false"/>
<ownedAttribute xmi:id="AAAAAAFardf7yrvrcg8=" name="Role2" visibility="public" isStatic="false" isLeaf="false" isReadOnly="false" isOrdered="false" isUnique="false" xmi:type="uml:Property" aggregation="none" isDerived="false" isID="false"/>
<ownedAttribute xmi:id="AAAAAAFardxJILwQ1Co=" name="Role3" visibility="public" isStatic="false" isLeaf="false" isReadOnly="false" isOrdered="false" isUnique="false" xmi:type="uml:Property" aggregation="none" isDerived="false" isID="false"/>
<ownedAttribute xmi:id="AAAAAAFard3TVLwyteg=" name="Role4" visibility="public" isStatic="false" isLeaf="false" isReadOnly="false" isOrdered="false" isUnique="false" xmi:type="uml:Property" aggregation="none" isDerived="false" isID="false"/>
</packagedElement>
<packagedElement xmi:id="AAAAAAFardeb5LvGhG0=" name="Actor1" visibility="public" isAbstract="false" isFinalSpecialization="false" isLeaf="false" xmi:type="uml:Actor"/>
</packagedElement>
</uml:Model>
</xmi:XMI>
使用SaxParser
检索此xml,例如:我想在消息元素中检索属性“name:”,但约束条件是消息必须{{1} }}。
我已经创建了使用messageSort="synchCall"
获取生命线和消息元素名称的代码:
SaxParser
但是当我想要使用约束来检索消息中的名称时,我需要更加具体:qLength = qName.length();
for (int i = 0; i < qLength; i++) {
String qValuename = qName.toString().toLowerCase();
if (qValuename.equalsIgnoreCase("lifeline")) {
length = attributes.getLength();
for (int j = 0; j < length; j++) {
String attrName = attributes.getLocalName(j);
if (attrName.compareToIgnoreCase("name") == 0) {
String val = attributes.getValue(j);
System.out.println("FunctionsName: " + val);
}
}
} else if (qValuename.equalsIgnoreCase("message")) {
length = attributes.getLength();
for (int j = 0; j < length; j++) {
String attrName = attributes.getLocalName(j);
if (attrName.compareToIgnoreCase("name") == 0) {
String val = attributes.getValue(j);
System.out.println("Message: " + val);
}
}
}
break;
}