Я попытался проверить XML по XSD следующим образом.
<?php
$xml= new DOMDocument;
$xml->load(xml path);
if ($xml->schemaValidate(xsd path)) {print "valid.\n";} else {print "invalid.\n";}
?>
Это дает мне следующую ошибку
DOMDocument::schemaValidate(): Element '{http://www.w3.org/2001/XMLSchema}attribute': The content is not valid. Expected is (annotation?).
Чтобы увидеть подробности ошибки, я добавляю libxml_use_internal_errors(true);
в коде проверки, как вы можете видеть ниже.
<?php
libxml_use_internal_errors(true);
$xml= new DOMDocument;
$xml->load(xml path);
if ($xml->schemaValidate(xsd path)) {print "valid.\n";} else {print "invalid.\n";}
?>
После добавления этого я получил следующее предупреждение
Severity: Warning
Message: DOMDocument::schemaValidate(): Invalid Schema
Я проверил это xml онлайн с моим xsd, и оно действительно Однако, в моем php коде это дает мне ошибку, и я гуглю эти ошибки, и это говорит, что документ мог быть недействительным, хотя я уверен, что документ корректен, поскольку я проверил это онлайн. Я немного новичок в этом, поэтому, возможно, есть какая-то ошибка, которую я делаю в коде проверки, но не вижу.
Здесь XML
<Application xmlns="NextGenMALI-Schema" Type="NewApplication">
<Identifier>1584928194</Identifier>
<SalesChannel SalesChannelType="Broker">
<Identifier>I12345</Identifier>
<CompanyName BusinessName="National Finance and Loans"/>
<PersonName>
<NameTitle Value="Mr"/>
<FirstName>Jonson</FirstName>
<Surname>Jonson</Surname>
</PersonName>
<RelatedEntityRef Type="crm_id">abc@yahoo.com</RelatedEntityRef>
<Email>abc@yahoo.com</Email>
</SalesChannel>
<SalesChannel SalesChannelDescription="BDM">
<Identifier/>
<PersonName>
<Surname/>
</PersonName>
</SalesChannel>
<Comment>Test comments.</Comment>
<PartySegment>
<Party Type="Applicant" PrimaryApplicant="Yes">
<Identifier>4</Identifier>
<Privacy AllowCreditCheck="Yes" AllowDirectMarketing="No" SignatureVerification="No" PointVerificationCompleted="No" ExistingCustomer="Yes" AllowThirdPartyDisclosure="Yes">
<PointVerification DocumentType="DriversLicenceAust" DocumentNumber="12345" NameOnDocument="Josie Ann Test" VersionSighted="Original" VerificationCategory="Primary" Photographic="Yes" NameVerified="Yes" AddressVerified="Yes" SignatureVerified="Yes" DOBVerified="Yes">
<PlaceOfIssue>
<City>NSW</City>
</PlaceOfIssue>
<EndDate>2014-11-28</EndDate>
</PointVerification>
<DocumentsSightedBy LoanWriter="No"/>
</Privacy>
<ResponsibleLend/>
<Person FirstHomeBuyer="Yes" CustomerOfLender="Yes" EmployeeOfLender="Yes" Director="No" PreviousName="Jones" Sex="Female">
<PersonName>
<NameTitle Value="Mr"/>
<FirstName>First Name</FirstName>
<OtherName>Middle Name</OtherName>
<Surname>Surname</Surname>
</PersonName>
<DateOfBirth>1993-02-01</DateOfBirth>
<MaritalStatus Status="Single" OtherDescription=""/>
<Dependent Age="2"/><Dependent Age="4"/>
<MothersMaidenName>Mother Maiden Name</MothersMaidenName>
<Residency PermanentInAustralia="Yes" Status="Citizen">
<Country ISO3166="AU"/>
</Residency>
<ContactDetails>
<AddressDetails Residential="Yes" Mailing="No" PriorAddress="No" PostSettlement="No" HousingStatus="Boarding">
<RelatedEntityRef>45e7815c217b8a</RelatedEntityRef>
<StartAndEndDates><StartDate>2019-04-04</StartDate></StartAndEndDates>
</AddressDetails><AddressDetails Residential="No" Mailing="No" PriorAddress="No" PostSettlement="No" HousingStatus="Caravan">
<RelatedEntityRef>45e7815c217ba4</RelatedEntityRef>
<StartAndEndDates><StartDate>2017-02-02</StartDate><EndDate>2017-02-02</EndDate></StartAndEndDates>
</AddressDetails><AddressDetails Residential="No" Mailing="No" PriorAddress="No" PostSettlement="No" HousingStatus="Renting">
<RelatedEntityRef>45e7815c217bac</RelatedEntityRef>
<StartAndEndDates><StartDate>2015-03-01</StartDate><EndDate>2015-03-01</EndDate></StartAndEndDates>
</AddressDetails>
<Email PreferredContactMethod="Yes">asd@yahoo.com</Email>
</ContactDetails>
<Employment OnProbation="No" PrimaryEmployment="Yes" PriorEmployment="No" Role="1112-11" RoleDescription="General Manager">
<PAYE Type="FullTime">
<RelatedEntityRef Type="RelatedParty">1097796810218</RelatedEntityRef>
</PAYE>
<StartAndEndDates>
<StartDate>2005-01-01</StartDate>
</StartAndEndDates>
<EmploymentIncome>
<ValueItem Value="10000">
<Identifier>IDARAHXC-Income</Identifier>
<Income Type="OtherIncome">
<Period Unit="Monthly">
<StartDate>2013-07-01</StartDate>
<EndDate>2014-06-30</EndDate>
</Period>
</Income>
</ValueItem>
</EmploymentIncome>
</Employment>
</Person>
</Party>
</PartySegment>
<AddressSegment>
<AddressWrapper>
<Identifier>45e7815c217b8a</Identifier>
<Address>
<StreetNo>8</StreetNo><Street Type="Street">Street</Street><City>Melbourne</City><State Name="VIC"/><Postcode>3000</Postcode>
<Country ISO3166="AU"/>
</Address>
</AddressWrapper>
<AddressWrapper>
<Identifier>45e7815c217ba4</Identifier>
<Address>
<StreetNo>4</StreetNo><Street Type="Street">Street</Street><City>Melville</City><State Name="WA"/><Postcode>6153</Postcode>
<Country ISO3166="AU"/>
</Address>
</AddressWrapper>
<AddressWrapper>
<Identifier>45e7815c217bac</Identifier>
<Address>
<StreetNo>7</StreetNo><Street Type="Street">Street</Street><City>Shire of Mornington Peninsula</City><State Name="VIC"/><Postcode>3941</Postcode>
<Country ISO3166="AU"/>
</Address>
</AddressWrapper>
</AddressSegment>
<FinancialSegment NoOtherAssets="No" NoLiabilities="No" NoIncome="No">
<ValueItem Value="41000">
<Identifier>1097796822609</Identifier>
<OwnedByAllApplicants/>
<Asset Class="CurrentSecurity" SecurityType="RegisteredMortgage">
<RealEstate Transaction="Purchasing" PrimarySecurity="Yes" PropertyPrimaryPurpose="OwnerOccupied" ApprovalInPrinciple="No" Status="Established" Holding="Sole">
<Residential WillOwn3UnitsInComplex="No" WillOwn25PercentOfComplex="No" OffThePlan="No" Type="FullyDetachedHouse"/>
<EstimatedValue>41000</EstimatedValue>
<ContractPrice LicencedRealEstateAgentContract="No" ContractPriceAmount="41000"/>
<VisitContact Type="Customer"/>
<Location>
<RelatedEntityRef>1415066564285</RelatedEntityRef>
<Title TitleType="Torrens" TenureType="Freehold"/>
</Location>
</RealEstate>
</Asset>
</ValueItem>
</FinancialSegment>
<RelatedPartySegment>
<RelatedParty RelPartyType="Lender">
<Identifier>1097796817156</Identifier>
<CompanyName BusinessName="AMP"/>
</RelatedParty>
</RelatedPartySegment>
<LoanDetailSegment>
<LoanDetails>
<Identifier>1097796802265</Identifier>
<EstimatedSettlement>2014-11-28</EstimatedSettlement>
<LoanPurpose PrimaryPurpose="OwnerOccupied" OwnerBuilderApplication="No">
<LendingPurposeCode ABSCode="ABS-125" PurposeAmount="0.0" Description="Affinity Fixed Rate, 1 Year (Investment)"/>
</LoanPurpose>
<LoanPortion ProductName="Affinity Fixed Rate, 1 Year (Investment)" ProductCode="AFFR1I" StatementCycle="Monthly" PackageName="">
<Identifier>1097796802265-1</Identifier>
<LoanTerm Units="Years" Type="TotalTerm">30</LoanTerm>
<LoanTerm Units="Years" Type="Variable" PaymentType="PrincipalAndInterest"/>
<AmountRequested Amount="41315" BaseAmount="41315"/>
<PaymentPeriod Payments="0.0">
<Period Unit="Monthly"/>
</PaymentPeriod>
</LoanPortion>
</LoanDetails>
<Representation Self="No">
<NominatedRepresentation>
<RelatedEntityRef>1415066458059</RelatedEntityRef>
</NominatedRepresentation>
</Representation>
</LoanDetailSegment>
<CrossSellSegment Enabled="true"/>
</Application>
<!-- NGPH: 237119.297 -->
Пожалуйста, найдите здесь XSD (Word превышен лимит, поэтому мне пришлось загрузить его, чтобы поделиться им с вами) https://easyupload.io/qifnk1 пароль: myxsd