C# C语言中的XML规范化#
我试图通过使用XPATH表达式创建XML输入的规范形式,但是我不确定是否能够从文档中接收到正确的输出 目前我正在使用这个表达式,但我希望能够使用显示的第二个表达式,但是这不会返回任何结果 我添加了这个名称空间,否则顶部也不起作用C# C语言中的XML规范化#,c#,xml,canonicalization,C#,Xml,Canonicalization,我试图通过使用XPATH表达式创建XML输入的规范形式,但是我不确定是否能够从文档中接收到正确的输出 目前我正在使用这个表达式,但我希望能够使用显示的第二个表达式,但是这不会返回任何结果 我添加了这个名称空间,否则顶部也不起作用 xmlnsManager.AddNamespace("x", "http://www.mytest.uk/tester"); 当前XPATH- x:testApplications/descendant-or-self::node()|//x:testApplicat
xmlnsManager.AddNamespace("x", "http://www.mytest.uk/tester");
当前XPATH-
x:testApplications/descendant-or-self::node()|//x:testApplications//@*
预期XPATH-
/testApplicationsBatch/testApplications|/testApplicaitonsBatch/testApplications//*
在XPathVisualizer中,预期的路径为我提供了正确的输出,但在.NET中则没有
XML文档
<testApplicationsBatch xmlns="http://www.mytest.uk/tester" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mytest.uk/test testApplications.xsd">
<testMessageHeader>
<MessageID>00000020</MessageID>
<RegisteredBody>20130900006</RegisteredBody>
<Timestamp>2013-06-21T11:34:02</Timestamp>
<MessageCheck>8iOc6vuolwy1pFlfaSJcLZKPSruLlhYuXeTw1hCRAYi9N3MynGveElyECPyZUOBJ</MessageCheck>
</testMessageHeader>
<testApplications>
<testApplication>
<ApplicantDetails>
<Title>DR</Title>
<Forename>REJECT</Forename>
<Middlenames>
<Middlename>INTEGRITY</Middlename>
</Middlenames>
<PresentSurname>VALIDATIONTESTCASETWELVE</PresentSurname>
<CurrentAddress>
<Address>
<AddressLine1>10 LODGE COURT</AddressLine1>
<AddressTown>STAINING</AddressTown>
<AddressCounty>LANCASHIRE</AddressCounty>
<Postcode>FY3 0EJ</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentFromGyearMonth>2003-07</ResidentFromGyearMonth>
</CurrentAddress>
<DateOfBirth>1977-01-01</DateOfBirth>
<Gender>male</Gender>
<NINumber>NM433816D</NINumber>
<AdditionalApplicantDetails>
<BirthTown>BLACKPOOL</BirthTown>
<BirthCounty>LANCASHIRE</BirthCounty>
<BirthCountry>GB</BirthCountry>
<BirthNationality>BRITISH</BirthNationality>
<ContactNumber>01253 897888</ContactNumber>
<UnspentConvictions>n</UnspentConvictions>
<DeclarationByApplicant>y</DeclarationByApplicant>
<LanguagePreference>english</LanguagePreference>
</AdditionalApplicantDetails>
<ApplicantIdentityDetails>
<IdentityVerified>y</IdentityVerified>
<EvidenceCheckedBy>RICHARD SMITH</EvidenceCheckedBy>
</ApplicantIdentityDetails>
</ApplicantDetails>
<PotentialEmployerDetails>
<PositionAppliedFor>HEAD TEACHER</PositionAppliedFor>
<OrganisationName>HODGSON HIGH SCHOOL</OrganisationName>
</PotentialEmployerDetails>
<RBdetails>
<RBApplicationReference>D00000128</RBApplicationReference>
<RBNumber>20130900006</RBNumber>
<CSigNumber>20130900021</CSigNumber>
<DisclosureType>standard</DisclosureType>
<WorkingWithVulnerableAdults>n</WorkingWithVulnerableAdults>
<WorkingWithChildren>n</WorkingWithChildren>
<CurrentAddressDetailsChecked>y</CurrentAddressDetailsChecked>
<Volunteer>y</Volunteer>
<WorkingAtHomeAddress>n</WorkingAtHomeAddress>
</RBdetails>
</testApplication>
</testApplications>
</testApplicationsBatch>
<testApplications xmlns="http://www.mytest.uk/tester" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<testApplication>
<ApplicantDetails>
<Title>MRS</Title>
<Forename>A'BCD THISISTEST CASEONEFORENAME</Forename>
<Middlenames>
<Middlename>MIDDLENAMEOFTESTCASEONE</Middlename>
</Middlenames>
<PresentSurname>ABCDEFTHISISTESTCASEONESURNAME</PresentSurname>
<CurrentAddress>
<Address>
<AddressLine1>28 BROCKLEWOOD'S AVENUE</AddressLine1>
<AddressLine2>NEAR/HIGHCROSS-(PUB)</AddressLine2>
<AddressTown>POULTON-LE-FYLDE</AddressTown>
<AddressCounty>LANCASHIRE-TEST-COUNTY</AddressCounty>
<Postcode>FY6 7SJ</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentFromGyearMonth>2013-07</ResidentFromGyearMonth>
</CurrentAddress>
<PreviousAddress>
<Address>
<AddressLine1>1(FLAT2) CUMBERLAND HOUSE</AddressLine1>
<AddressLine2>A'B-C THISISTESTCASEONEADDRESSLINETWO</AddressLine2>
<AddressTown>ABERYSTH-TOWN</AddressTown>
<AddressCounty>G</AddressCounty>
<Postcode>L2 0QN</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentDates>
<ResidentFromGyearMonth>1997-01</ResidentFromGyearMonth>
<ResidentToGyearMonth>2013-07</ResidentToGyearMonth>
</ResidentDates>
</PreviousAddress>
<DateOfBirth>1977-01-13</DateOfBirth>
<Gender>female</Gender>
<NINumber>NM433816D</NINumber>
<AdditionalApplicantDetails>
<BirthSurname>A'B-CBIRTHSURNAME</BirthSurname>
<BirthSurnameUntil>2000</BirthSurnameUntil>
<OtherSurnames>
<OtherSurname>
<Name>OTHER SURNAME NAME</Name>
<UsedFrom>2000</UsedFrom>
<UsedTo>2000</UsedTo>
</OtherSurname>
</OtherSurnames>
<OtherForenames>
<OtherForename>
<Name>OTHERFORENAMENAMETESTONE</Name>
<UsedFrom>1977</UsedFrom>
<UsedTo>2000</UsedTo>
</OtherForename>
</OtherForenames>
<BirthTown>ASHTON-UNDER-LYME</BirthTown>
<BirthCounty>/1-'&COUNTYTESTONE</BirthCounty>
<BirthCountry>WS</BirthCountry>
<BirthNationality>GERMAN/-0'FRENCH</BirthNationality>
<ContactNumber>01253 897888/EXT - 1234</ContactNumber>
<UnspentConvictions>y</UnspentConvictions>
<DeclarationByApplicant>y</DeclarationByApplicant>
<LanguagePreference>english</LanguagePreference>
</AdditionalApplicantDetails>
<ApplicantIdentityDetails>
<IdentityVerified>y</IdentityVerified>
<EvidenceCheckedBy>RICHARD SMITH</EvidenceCheckedBy>
<PassportDetails>
<PassportNumber>12345678912</PassportNumber>
<PassportDob>1977-01-13</PassportDob>
<PassportNationality>BRITISH</PassportNationality>
<PassportIssueDate>2001-01-13</PassportIssueDate>
</PassportDetails>
<DriverLicenceDetails>
<DriverLicenceNumber>ABCDE 701017 AB1CS</DriverLicenceNumber>
<DriverLicenceDOB>1977-01-13</DriverLicenceDOB>
<DriverLicenceType>paper</DriverLicenceType>
<DriverLicenceValidFrom>2003-01-02</DriverLicenceValidFrom>
<DriverLicenceIssueCountry>IO</DriverLicenceIssueCountry>
</DriverLicenceDetails>
</ApplicantIdentityDetails>
</ApplicantDetails>
<PotentialEmployerDetails>
<PositionAppliedFor>CARETAKER'S ASSISTANT</PositionAppliedFor>
<OrganisationName>BIDE-A-WEE REST HOME'S/(ELDERLY&INFIRM)</OrganisationName>
</PotentialEmployerDetails>
<RBdetails>
<RBApplicationReference>ARM16</RBApplicationReference>
<RBNumber>20130800000</RBNumber>
<CSigNumber>20130800025</CSigNumber>
<DisclosureType>standard</DisclosureType>
<WorkingWithVulnerableAdults>n</WorkingWithVulnerableAdults>
<WorkingWithChildren>n</WorkingWithChildren>
<CurrentAddressDetailsChecked>y</CurrentAddressDetailsChecked>
<Volunteer>y</Volunteer>
<WorkingAtHomeAddress>n</WorkingAtHomeAddress>
</RBdetails>
</testApplication>
</testApplications>
00000020
20130900006
2013-06-21T11:34:02
8IOC6Vuolwy1PFLJCLZKPsrullHyux1HcRayi9N3YNGVEEEECPYZUOBJ
博士
拒绝
诚实正直
验证测试用例12
10洛奇法院
染色
兰开夏郡
FY3 0EJ
国标
2003-07
1977-01-01
男性的
NM433816D
布莱克浦
兰开夏郡
国标
英国的
01253 897888
N
Y
英语
Y
理查德·史密斯
班主任
霍奇森高中
D00000128
20130900006
20130900021
标准
N
N
Y
Y
N
返回的规范文档
<testApplicationsBatch xmlns="http://www.mytest.uk/tester" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mytest.uk/test testApplications.xsd">
<testMessageHeader>
<MessageID>00000020</MessageID>
<RegisteredBody>20130900006</RegisteredBody>
<Timestamp>2013-06-21T11:34:02</Timestamp>
<MessageCheck>8iOc6vuolwy1pFlfaSJcLZKPSruLlhYuXeTw1hCRAYi9N3MynGveElyECPyZUOBJ</MessageCheck>
</testMessageHeader>
<testApplications>
<testApplication>
<ApplicantDetails>
<Title>DR</Title>
<Forename>REJECT</Forename>
<Middlenames>
<Middlename>INTEGRITY</Middlename>
</Middlenames>
<PresentSurname>VALIDATIONTESTCASETWELVE</PresentSurname>
<CurrentAddress>
<Address>
<AddressLine1>10 LODGE COURT</AddressLine1>
<AddressTown>STAINING</AddressTown>
<AddressCounty>LANCASHIRE</AddressCounty>
<Postcode>FY3 0EJ</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentFromGyearMonth>2003-07</ResidentFromGyearMonth>
</CurrentAddress>
<DateOfBirth>1977-01-01</DateOfBirth>
<Gender>male</Gender>
<NINumber>NM433816D</NINumber>
<AdditionalApplicantDetails>
<BirthTown>BLACKPOOL</BirthTown>
<BirthCounty>LANCASHIRE</BirthCounty>
<BirthCountry>GB</BirthCountry>
<BirthNationality>BRITISH</BirthNationality>
<ContactNumber>01253 897888</ContactNumber>
<UnspentConvictions>n</UnspentConvictions>
<DeclarationByApplicant>y</DeclarationByApplicant>
<LanguagePreference>english</LanguagePreference>
</AdditionalApplicantDetails>
<ApplicantIdentityDetails>
<IdentityVerified>y</IdentityVerified>
<EvidenceCheckedBy>RICHARD SMITH</EvidenceCheckedBy>
</ApplicantIdentityDetails>
</ApplicantDetails>
<PotentialEmployerDetails>
<PositionAppliedFor>HEAD TEACHER</PositionAppliedFor>
<OrganisationName>HODGSON HIGH SCHOOL</OrganisationName>
</PotentialEmployerDetails>
<RBdetails>
<RBApplicationReference>D00000128</RBApplicationReference>
<RBNumber>20130900006</RBNumber>
<CSigNumber>20130900021</CSigNumber>
<DisclosureType>standard</DisclosureType>
<WorkingWithVulnerableAdults>n</WorkingWithVulnerableAdults>
<WorkingWithChildren>n</WorkingWithChildren>
<CurrentAddressDetailsChecked>y</CurrentAddressDetailsChecked>
<Volunteer>y</Volunteer>
<WorkingAtHomeAddress>n</WorkingAtHomeAddress>
</RBdetails>
</testApplication>
</testApplications>
</testApplicationsBatch>
<testApplications xmlns="http://www.mytest.uk/tester" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<testApplication>
<ApplicantDetails>
<Title>MRS</Title>
<Forename>A'BCD THISISTEST CASEONEFORENAME</Forename>
<Middlenames>
<Middlename>MIDDLENAMEOFTESTCASEONE</Middlename>
</Middlenames>
<PresentSurname>ABCDEFTHISISTESTCASEONESURNAME</PresentSurname>
<CurrentAddress>
<Address>
<AddressLine1>28 BROCKLEWOOD'S AVENUE</AddressLine1>
<AddressLine2>NEAR/HIGHCROSS-(PUB)</AddressLine2>
<AddressTown>POULTON-LE-FYLDE</AddressTown>
<AddressCounty>LANCASHIRE-TEST-COUNTY</AddressCounty>
<Postcode>FY6 7SJ</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentFromGyearMonth>2013-07</ResidentFromGyearMonth>
</CurrentAddress>
<PreviousAddress>
<Address>
<AddressLine1>1(FLAT2) CUMBERLAND HOUSE</AddressLine1>
<AddressLine2>A'B-C THISISTESTCASEONEADDRESSLINETWO</AddressLine2>
<AddressTown>ABERYSTH-TOWN</AddressTown>
<AddressCounty>G</AddressCounty>
<Postcode>L2 0QN</Postcode>
<CountryCode>GB</CountryCode>
</Address>
<ResidentDates>
<ResidentFromGyearMonth>1997-01</ResidentFromGyearMonth>
<ResidentToGyearMonth>2013-07</ResidentToGyearMonth>
</ResidentDates>
</PreviousAddress>
<DateOfBirth>1977-01-13</DateOfBirth>
<Gender>female</Gender>
<NINumber>NM433816D</NINumber>
<AdditionalApplicantDetails>
<BirthSurname>A'B-CBIRTHSURNAME</BirthSurname>
<BirthSurnameUntil>2000</BirthSurnameUntil>
<OtherSurnames>
<OtherSurname>
<Name>OTHER SURNAME NAME</Name>
<UsedFrom>2000</UsedFrom>
<UsedTo>2000</UsedTo>
</OtherSurname>
</OtherSurnames>
<OtherForenames>
<OtherForename>
<Name>OTHERFORENAMENAMETESTONE</Name>
<UsedFrom>1977</UsedFrom>
<UsedTo>2000</UsedTo>
</OtherForename>
</OtherForenames>
<BirthTown>ASHTON-UNDER-LYME</BirthTown>
<BirthCounty>/1-'&COUNTYTESTONE</BirthCounty>
<BirthCountry>WS</BirthCountry>
<BirthNationality>GERMAN/-0'FRENCH</BirthNationality>
<ContactNumber>01253 897888/EXT - 1234</ContactNumber>
<UnspentConvictions>y</UnspentConvictions>
<DeclarationByApplicant>y</DeclarationByApplicant>
<LanguagePreference>english</LanguagePreference>
</AdditionalApplicantDetails>
<ApplicantIdentityDetails>
<IdentityVerified>y</IdentityVerified>
<EvidenceCheckedBy>RICHARD SMITH</EvidenceCheckedBy>
<PassportDetails>
<PassportNumber>12345678912</PassportNumber>
<PassportDob>1977-01-13</PassportDob>
<PassportNationality>BRITISH</PassportNationality>
<PassportIssueDate>2001-01-13</PassportIssueDate>
</PassportDetails>
<DriverLicenceDetails>
<DriverLicenceNumber>ABCDE 701017 AB1CS</DriverLicenceNumber>
<DriverLicenceDOB>1977-01-13</DriverLicenceDOB>
<DriverLicenceType>paper</DriverLicenceType>
<DriverLicenceValidFrom>2003-01-02</DriverLicenceValidFrom>
<DriverLicenceIssueCountry>IO</DriverLicenceIssueCountry>
</DriverLicenceDetails>
</ApplicantIdentityDetails>
</ApplicantDetails>
<PotentialEmployerDetails>
<PositionAppliedFor>CARETAKER'S ASSISTANT</PositionAppliedFor>
<OrganisationName>BIDE-A-WEE REST HOME'S/(ELDERLY&INFIRM)</OrganisationName>
</PotentialEmployerDetails>
<RBdetails>
<RBApplicationReference>ARM16</RBApplicationReference>
<RBNumber>20130800000</RBNumber>
<CSigNumber>20130800025</CSigNumber>
<DisclosureType>standard</DisclosureType>
<WorkingWithVulnerableAdults>n</WorkingWithVulnerableAdults>
<WorkingWithChildren>n</WorkingWithChildren>
<CurrentAddressDetailsChecked>y</CurrentAddressDetailsChecked>
<Volunteer>y</Volunteer>
<WorkingAtHomeAddress>n</WorkingAtHomeAddress>
</RBdetails>
</testApplication>
</testApplications>
夫人
A'BCD这是一个最新的案例
中间名测试用例一
ABCDEF这是一个姓
布罗克伍德大道28号
近/高交叉-(酒吧)
波尔顿勒费尔德酒店
兰开夏郡
FY6 7SJ
国标
2013-07
坎伯兰大厦1号(2层)
A'B-C这是案例一地址行二
阿伯里斯镇
G
L20QN
国标
1997-01
2013-07
1977-01-13
女性的
NM433816D
A'B-Cbirth姓氏
2000
其他姓氏
2000
2000
OtherForeNameTestOne
1977
2000
阿什顿莱姆酒店
/(一)"及;伯爵石
WS
德语/-0'法语
01253 897888/分机-1234
Y
Y
英语
Y
理查德·史密斯
12345678912
1977-01-13
英国的
2001-01-13
ABCDE 701017 AB1CS
1977-01-13
纸张
2003-01-02
木卫一
管理员助理
养老院/(老人和体弱者)
ARM16
20130800000
20130800025
标准
N
N
Y
Y
N
如果您使用xpath表达式,请提供示例代码。在.net framework中提供了多个XML API,了解您使用的是哪种API会很有帮助。什么是“XML的规范形式”?看起来您正在尝试将空名称空间前缀映射到非空名称空间,这在.Net中是不可能的。或者,您可能希望将所有节点移动到空名称空间(这不是示例的样子)…我正在使用XmlDsigC14NTransform类生成规范格式。我正在尝试选择文档的testApplication部分,并生成该部分的规范格式(如果这更有意义的话)。您肯定不希望在签名期间更改节点的命名空间。不幸的是,我无法帮助您了解详细信息,因为我从未直接对XML进行过签名。您可能想用简短的示例代码和更小的XML示例重写您的问题。。。还要考虑添加链接到MSDN文章,这些代码是你用来编写代码的,所以人们知道你已经尝试了什么。