Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3843

Standard namespace prefixes should not be used for unexpected namespaces

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Use a different prefix for this namespace.
    • Highlighting:
      Hide

      xmlns:xxx

      Show
      xmlns:xxx
    • List of parameters:
      Hide

      key: reservedPrefixes
      descriptions: Comma-delimited list of namespace prefixes that should not be used
      default value: xml,xmlns,xs,xsd,xsi,wsdl

      Show
      key: reservedPrefixes descriptions: Comma-delimited list of namespace prefixes that should not be used default value: xml,xmlns,xs,xsd,xsi,wsdl
    • Default Severity:
      Critical
    • Impact:
      High
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      XML
    • Irrelevant for Languages:
      ABAP, C#, C, C++, Cobol, CSS, Flex, HTML, Java, JavaScript, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Swift, VB.Net, VB6
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      15min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      Certain prefixes are widely recognized and expected to correspond to specific namespaces. For instance, most users will expect "xs" to correspond to "http://www.w3.org/2001/XMLSchema". If you subvert that expected correspondence, you run the risk of severely confusing the users of your XSD.

      Noncompliant Code Example

      <xs:schema targetNamespace="http://www.codeSamples.com/fruit"
                 elementFormDefault="qualified" version="1"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns:wsdl="http://CodeSamples.com/animal>       <!-- Noncompliant -->
      ...
      

      Compliant Solution

      <xs:schema targetNamespace="http://www.codeSamples.com/fruit"
                 elementFormDefault="qualified" version="1"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns:animal="http://CodeSamples.com/animal>
      ...
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ann.campbell.2 Ann Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: