<?xml version="1.0" encoding="utf-8"?>
<!--
  SSRS2's own report items and styles, in SSRS2's namespace (https://ssrs2.net/schemas/2026/reportdefinition).

  RDL's schema lets a report hold elements of another namespace among its report items and in a table's cells: Report
  Viewer and SSRS skip them, and the report runs there without them. SSRS2 draws them. A report that uses one declares
  the namespace on its root element:

    <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition"
            xmlns:ssrs2="http://ssrs2.net/schemas/2026/reportdefinition">

  Everything an item holds is in SSRS2's namespace, its place, size, style, visibility, tooltip, bookmark and action
  too: they have RDL's names and content (Top, Left, Height, Width, ZIndex, Style, Visibility, ToolTip, Bookmark,
  DocumentMapLabel, ActionInfo...), written with the ssrs2 prefix. Report Viewer refuses a report whose element of
  another namespace holds an element of RDL's ("No declaration found for the report definition element"). A value may
  be an expression ("=Fields!Code.Value"), as in RDL.
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://ssrs2.net/schemas/2026/reportdefinition"
            targetNamespace="http://ssrs2.net/schemas/2026/reportdefinition"
            elementFormDefault="qualified">

  <xsd:element name="Barcode" type="BarcodeType">
    <xsd:annotation>
      <xsd:documentation>
        A barcode or QR code. SSRS2 draws its modules as vectors in PDF and as pixels in images; Word, Excel and HTML
        show its bitmap at 300 dpi. A linear code shows its value's text under its bars (EAN and UPC with their check
        digit). In a table's cell, it takes the cell's size.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:element name="CornerRadius" type="CornerRadiusType">
    <xsd:annotation>
      <xsd:documentation>
        A text box's or a rectangle's rounded corners, in its RDL Style (RDL's schema takes an element of another
        namespace there: Report Viewer and SSRS skip it and draw the box square). One length for the four corners, or
        four: top left, top right, bottom right and bottom left, as CSS's border-radius writes them (8pt, or 8pt 8pt 0pt
        0pt for the top ones), in pt, in, cm, mm, pc or px; a constant, not an expression. A radius too large for its box
        is made smaller as CSS makes it, and a corner on an edge a page cuts is square. SSRS2 rounds the box's
        background, its picture and its borders in PDF, image output and PowerPoint; HTML, Word and Excel draw the box
        square, and so does a table's cell.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:element name="Shape" type="ShapeType">
    <xsd:annotation>
      <xsd:documentation>
        A text box's or a rectangle's shape, in its RDL Style (Report Viewer and SSRS skip it and draw the box): Ellipse,
        Diamond (a flowchart's decision) or Cylinder (a database: its lid a quarter of its shorter side high), whatever
        their capitals; a constant. SSRS2 draws, fills and clips the box so in PDF and image output, and PowerPoint's own
        shape (ellipse, diamond, can) in a deck, its connectors glued to it; its outline is its top border's pen (a
        double one single). A shape a page cuts is drawn square; HTML, Word and Excel draw the box, and so does a
        table's cell. A Shape wins over a CornerRadius.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:element name="StartArrow" type="ArrowType">
    <xsd:annotation>
      <xsd:documentation>
        A line's arrowhead at its start (its Left and Top), in its RDL Style (RDL's schema takes an element of another
        namespace there: Report Viewer and SSRS skip it and draw the line bare). PowerPoint's line ends: Triangle, Arrow
        (open), Stealth, Diamond or Oval, or None; three times the line's width long and wide. SSRS2 draws it in PDF,
        image output and PowerPoint (its own line end); HTML, Word and Excel draw the line bare.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:element name="EndArrow" type="ArrowType">
    <xsd:annotation>
      <xsd:documentation>
        A line's arrowhead at its end (its Left plus Width, its Top plus Height), as StartArrow at its start.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:element name="HeaderRows" type="xsd:positiveInteger">
    <xsd:annotation>
      <xsd:documentation>
        A table's header rows, in its RDL Tablix (RDL's schema takes an element of another namespace there: Report Viewer
        and SSRS skip it and show the header once): its first N rows are repeated at the top of each page the table goes
        on to. RDL repeats a static row only beside a group (KeepWithGroup, RepeatOnNewPage); this is for a table of
        static rows, which has none: a Markdown document's. SSRS2 repeats them in PDF, image output and PowerPoint, and
        marks them as Word's header rows. Only in a table without groups, row or column headers, whose header rows have a
        cell for each column, none spanning, and no visibility of their own; elsewhere it is skipped.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:simpleType name="ShapeType">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="\s*([Ee][Ll][Ll][Ii][Pp][Ss][Ee]|[Dd][Ii][Aa][Mm][Oo][Nn][Dd]|[Cc][Yy][Ll][Ii][Nn][Dd][Ee][Rr])\s*" />
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="ArrowType">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="\s*([Nn][Oo][Nn][Ee]|[Tt][Rr][Ii][Aa][Nn][Gg][Ll][Ee]|[Aa][Rr][Rr][Oo][Ww]|[Ss][Tt][Ee][Aa][Ll][Tt][Hh]|[Dd][Ii][Aa][Mm][Oo][Nn][Dd]|[Oo][Vv][Aa][Ll])\s*" />
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="CornerRadiusType">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="\s*(\d+(\.\d+)?|\.\d+)\s*(pt|in|cm|mm|pc|px)?(\s*[,\s]\s*(\d+(\.\d+)?|\.\d+)\s*(pt|in|cm|mm|pc|px)?){3}\s*" />
      <xsd:pattern value="\s*(\d+(\.\d+)?|\.\d+)\s*(pt|in|cm|mm|pc|px)?\s*" />
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:complexType name="BarcodeType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="Symbology" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>
            QRCode, DataMatrix, GS1DataMatrix, PDF417, Aztec, Code128, GS1-128, Code39, Code93, EAN-13, EAN-8, UPC-A,
            UPC-E, ITF, Codabar, MSI, Plessey or Pharmacode (letters and digits count, case and punctuation do not: QR,
            ean13, UPC-A), or an expression giving one. Code128 when absent. SwissQRCode is a QR code with the Swiss cross.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="Value" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>
            What the code encodes: a text or an expression. GS1 data is written as application identifiers in
            parentheses: (01)09501101530003(10)AB12. An empty value draws nothing.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="ShowText" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>true (the default) or false: the value's text under a linear code's bars.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="ErrorCorrection" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>QR code: L, M (the default), Q or H. PDF417: 0 to 8. Aztec: a percentage, 5 to 95.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="QuietZone" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>
            true (the default) or false: the margin scanners need, inside the item's box (ten modules beside bars,
            four around a QR code, two beside PDF417, one around the others).
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="Rotation" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>0 (the default), 90, 180 or 270: the code turned clockwise, its text with it.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="Encoding" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>A 2D code's character set (UTF-8, ISO-8859-1, Shift_JIS...): UTF-8 when the text needs it by default.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <!-- What every report item has, with RDL's names and content, in SSRS2's namespace -->
      <xsd:element name="Top" type="xsd:string" />
      <xsd:element name="Left" type="xsd:string" />
      <xsd:element name="Height" type="xsd:string" />
      <xsd:element name="Width" type="xsd:string" />
      <xsd:element name="ZIndex" type="xsd:string" />
      <xsd:element name="ToolTip" type="xsd:string" />
      <xsd:element name="DocumentMapLabel" type="xsd:string" />
      <xsd:element name="Bookmark" type="xsd:string" />
      <xsd:element name="RepeatWith" type="xsd:string" />
      <xsd:element name="DataElementName" type="xsd:string" />
      <xsd:element name="DataElementOutput" type="xsd:string" />
      <xsd:element name="PageName" type="xsd:string" />
      <xsd:element name="Style" type="RdlContentType">
        <xsd:annotation>
          <xsd:documentation>RDL's Style: Color (the bars'), BackgroundColor, Border and its sides, the text's FontFamily, FontSize, FontWeight, FontStyle.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="Visibility" type="RdlContentType" />
      <xsd:element name="ActionInfo" type="RdlContentType" />
      <xsd:element name="PageBreak" type="RdlContentType" />
      <xsd:element name="CustomProperties" type="RdlContentType" />
      <!-- The report designer's own elements (rd:) -->
      <xsd:any namespace="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" processContents="skip" />
    </xsd:choice>
    <xsd:attribute name="Name" type="xsd:string" use="required" />
    <xsd:anyAttribute namespace="##other" processContents="skip" />
  </xsd:complexType>

  <!-- An RDL element's content (its type in RDL's schema), its elements in SSRS2's namespace -->
  <xsd:complexType name="RdlContentType" mixed="true">
    <xsd:sequence>
      <xsd:any namespace="##targetNamespace" processContents="skip" minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>
