none
Validation of PIDX XML documents RRS feed

  • Question

  • How do I get Visual Studio 2017 to validate and do auto-completion for PIDX XML documents?

    A couple of years ago, I worked with PIDX XML invoices all the time in Visual Studio.  I could have sworn that VS used to give warnings or errors about improper tags (e.g. warning on <SomeTag> but not on <pidx:SomeTag>) and provided autocomplete information based on the schema information.  Either I'm remembering wrong or something isn't quite right with my VS setup.

    I've added the 1.01 schemas from the PIDX.org website to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Xml\Schemas.  I've tried going into the XML menu tab and setting the "Use" property to both "Automatic" and "use this schema" with no noticeable change.  I've tried associating the schemas in the properties window of the XML document with no noticeable change.

    Am I just remember wrong or is there something special that I need to do?

    If it helps, here's some stripped-down code from an invoice document:

    <?xml version="1.0" encoding="utf-8"?>
    <pidx:Invoice pidx:transactionPurposeIndicator="Original" pidx:version="1.0" xmlns:pidx="http://www.api.org/pidXML/v1.01">
      <pidx:InvoiceProperties>
        <pidx:InvoiceNumber>123456789</pidx:InvoiceNumber>
        <pidx:InvoiceDate>2015-09-03</pidx:InvoiceDate>
        <pidx:PartnerInformation partnerRoleIndicator="Seller">
        </pidx:PartnerInformation>
        <pidx:PartnerInformation partnerRoleIndicator="Vendor">
        </pidx:PartnerInformation>
        <pidx:InvoiceTypeCode>ProductOrService</pidx:InvoiceTypeCode>
        <pidx:RevisionNumber />
        <pidx:PurchaseOrderInformation>
          <pidx:PurchaseOrderNumber></pidx:PurchaseOrderNumber>
        </pidx:PurchaseOrderInformation>
        <pidx:PrimaryCurrency>
          <pidx:CurrencyCode>USD</pidx:CurrencyCode>
        </pidx:PrimaryCurrency>
        <pidx:JobLocationInformation>
        </pidx:JobLocationInformation>
        <pidx:ServiceDateTime dateTypeIndicator="ServicePeriodStart">2015-09-02T00:00:00</pidx:ServiceDateTime>
        <pidx:ServiceDateTime dateTypeIndicator="ServicePeriodEnd">2015-09-02T00:00:00</pidx:ServiceDateTime>
        <pidx:PaymentTerms>
          <pidx:PaymentTermsOfSale>Net 30</pidx:PaymentTermsOfSale>
        </pidx:PaymentTerms>
        <pidx:ReferenceInformation referenceInformationIndicator="CostCenter">
          <pidx:ReferenceNumber></pidx:ReferenceNumber>
        </pidx:ReferenceInformation>
        <pidx:Attachment>
          <pidx:AttachmentPurposeCode>Other</pidx:AttachmentPurposeCode>
          <pidx:FileName>123456789.pdf</pidx:FileName>
        </pidx:Attachment>
        <pidx:Comment></pidx:Comment>
      </pidx:InvoiceProperties>
      <pidx:InvoiceDetails>
      </pidx:InvoiceDetails>
      <pidx:InvoiceSummary>
        <pidx:TotalLineItems>6</pidx:TotalLineItems>
        <pidx:InvoiceTotal>
        </pidx:InvoiceTotal>
        <pidx:Tax>
        </pidx:Tax>
      </pidx:InvoiceSummary>
    </pidx:Invoice>

    Friday, March 30, 2018 8:53 PM

Answers

All replies

  • Hi PPettitDN,

    Welcome to the MSDN forum.

    This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    According to your description, your issue is related to PIDX XML, I suggest you visit following forum for a professional answer.

    http://www.pidx.org/support-request-form/

    Thanks for your understanding.

    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Regards,

    Judyzh


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 2, 2018 3:12 AM
  • The forum that I posted in is "Visual Studio General Questions".  When you hover over the link to the forum in the left-hand column, it shows "Discuss and ask questions about general Visual Studio topics."  Nowhere do I see anything stating "This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor."  If there is a more appropriate forum to ask questions about the functionality of Visual Studio, please let me know.

    My question is primarily regarding how to get Visual Studio to properly validate XML (or if it can even be done).  The type of XML is not particularly important but was included to provide more precise information in case it mattered.  The PIDX forums are a much less appropriate place to ask questions about the functionality of Visual Studio.

    Monday, April 2, 2018 12:15 PM
  • Hi PPettitDN,

    >>My question is primarily regarding how to get Visual Studio to properly validate XML (or if it can even be done).

    I find following content might helpful for you, please take a look:

    #XmlDocument.Validate Method (ValidationEventHandler)

    #XML Validation with XSD in Visual Studio IDE

    #How to: Select the XML Schemas to Use

    Regards,

    Judyzh


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 3, 2018 5:06 AM
  • I've found the solution as well as some workarounds for my problem.

    To put it simply, once I was able to get the exact referenced schemas and "unblock" them in Windows File Explorer, validation and IntelliSense started working again.


    The workarounds involved editing the XML document to reference the namespace found in the schema you're using:

    <pidx:Invoice pidx:transactionPurposeIndicator="Original" pidx:version="1.0" xmlns:pidx="http://www.api.org/pidXML/v1.0">

    Instead of:

    <pidx:Invoice pidx:transactionPurposeIndicator="Original" pidx:version="1.0" xmlns:pidx="http://www.pidx.org/schemas/v1.01">

    or editing the schema ("targetNamespace" and "xmlns:pidx=" items) to reflect the namespace used in the XML document:

    <schema targetNamespace="http://www.pidx.org/schemas/v1.01" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:pidx="http://www.pidx.org/schemas/v1.01" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.01">

    To:

    <schema targetNamespace="http://www.api.org/pidXML/v1.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:pidx="http://www.api.org/pidXML/v1.0" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.01">


    • Marked as answer by PPettitDN Wednesday, April 4, 2018 12:55 PM
    Wednesday, April 4, 2018 12:54 PM
  • I was just doing a search on PIDX forums and this post came up.  I'm building a very similar system to what you previously built and are probably re-building.  
    Thursday, April 5, 2018 1:39 PM
  • I work with Brian N again, we should meet-up and do lunch.
    Thursday, April 5, 2018 1:43 PM