Friday, September 21, 2007

Powershell Format XML Schema (ps.formats.xsd) 

After I've found an XML schema for Powershell types last week but no one for formats I collected one which successfully validates Powershell and PSCX format files. It's also customized for VS.NET similar to Keith's types schema.
Download the schema file here: ps.formats.xsd

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema"

      xmlns:vs="http://schemas.microsoft.com/Visual-Studio-Intellisense"

      elementFormDefault="qualified"

      attributeFormDefault="unqualified"

      vs:friendlyname="PowerShell Format Data"

      vs:ishtmlschema="false"

      xmlns:psfd="http://schemas.microsoft.com/PowerShell/FormatData/2007/09"

      targetNamespace="http://schemas.microsoft.com/PowerShell/FormatData/2007/09">

  <xs:element name="Wrap">

    <xs:complexType/>

  </xs:element>

  <xs:element name="Width" type="xs:nonNegativeInteger">

    <xs:annotation>

      <xs:documentation>Contains the width of the column.</xs:documentation>

    </xs:annotation>

  </xs:element>

  <xs:element name="WideItem">

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:PropertyName" minOccurs="0"/>

        <xs:element ref="psfd:FormatString" minOccurs="0"/>

        <xs:element ref="psfd:ScriptBlock" minOccurs="0"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="WideEntry">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:EntrySelectedBy" minOccurs="0"/>

        <xs:element ref="psfd:WideItem"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="WideEntries">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:WideEntry" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="WideControl">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:WideEntries"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="ViewSelectedBy">

    <xs:annotation>

      <xs:documentation>Defines the .NET objects to which this view applies.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:SelectionSetName" minOccurs="0" maxOccurs="unbounded"/>

        <xs:element ref="psfd:TypeName" minOccurs="0" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="ViewDefinitions">

    <xs:annotation>

      <xs:documentation>Contains the definitions, referred to as views, for how object data is displayed.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:View" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="View">

    <xs:annotation>

      <xs:documentation>Contains the column and row definitions for a specific view. Note that a single view can be used by several objects.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:Name"/>

        <xs:element ref="psfd:OutOfBand" minOccurs="0"/>

        <xs:element ref="psfd:ViewSelectedBy"/>

        <xs:element ref="psfd:GroupBy" minOccurs="0"/>

        <xs:choice maxOccurs="unbounded">

          <xs:element ref="psfd:ListControl"/>

          <xs:element ref="psfd:TableControl"/>

          <xs:element ref="psfd:WideControl"/>

          <xs:element ref="psfd:CustomControl"/>

          <xs:element ref="psfd:Controls"/>

        </xs:choice>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="Types">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:TypeName" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="TypeName" type="xs:string">

    <xs:annotation>

      <xs:documentation>Contains the name of the .NET object to which the view applies.</xs:documentation>

    </xs:annotation>

  </xs:element>

  <xs:element name="Text">

    <xs:complexType>

      <xs:simpleContent>

        <xs:extension base="xs:string">

          <xs:attribute name="ResourceId" type="xs:string" use="optional"/>

          <xs:attribute name="BaseName" type="xs:string" use="optional"/>

          <xs:attribute name="AssemblyName" type="xs:string" use="optional"/>

        </xs:extension>

      </xs:simpleContent>

    </xs:complexType>

  </xs:element>

  <xs:element name="TableRowEntry">

    <xs:annotation>

      <xs:documentation>Defines the row information for the display view. This information defines what data is displayed in the columns of the display view, such as an object property or script block.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:Wrap" minOccurs="0"/>

        <xs:element ref="psfd:TableColumnItems"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="TableRowEntries">

    <xs:annotation>

      <xs:documentation>Defines the row information for the display view. This information defines what data is displayed in the columns of the display view, such as an object property or script block.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:TableRowEntry" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="TableHeaders">

    <xs:annotation>

      <xs:documentation>Defines the header information for the columns in the display view.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:TableColumnHeader" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="TableControl">

    <xs:annotation>

      <xs:documentation>Defines the column and row information for the display view.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:AutoSize" minOccurs="0"/>

        <xs:element ref="psfd:TableHeaders" minOccurs="0"/>

        <xs:element ref="psfd:TableRowEntries"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="TableColumnItems">

    <xs:annotation>

      <xs:documentation>Defines what type of data is displayed in each column of the display view, such as an object property or script block.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:TableColumnItem" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="TableColumnItem">

    <xs:annotation>

      <xs:documentation>Defines what type of data is displayed in a column of the display view, such as an object property or script block.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:PropertyName" minOccurs="0"/>

        <xs:element ref="psfd:ScriptBlock" minOccurs="0"/>

        <xs:element ref="psfd:FormatString" minOccurs="0"/>

        <xs:element ref="psfd:Alignment" minOccurs="0"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="TableColumnHeader">

    <xs:annotation>

      <xs:documentation>Defines the header information for a column in the display view.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:all>

        <xs:annotation>

          <xs:documentation>Label would be expected to be mandatory, but PS registry.format.ps1xml defines an empty TableColumnHeader element</xs:documentation>

        </xs:annotation>

        <xs:element ref="psfd:Label" minOccurs="0"/>

        <xs:element ref="psfd:Width" minOccurs="0"/>

        <xs:element ref="psfd:Alignment" minOccurs="0">

          <xs:annotation>

            <xs:documentation>Contains the alignment setting (Left, Centered, Right) that controls how the data is displayed in the column.</xs:documentation>

          </xs:annotation>

        </xs:element>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="SelectionSets">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:SelectionSet"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="SelectionSetName" type="xs:string"/>

  <xs:element name="SelectionSet">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:Name"/>

        <xs:element ref="psfd:Types"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="ScriptBlock" type="xs:string">

    <xs:annotation>

      <xs:documentation>Contains the script block that generates the data that is displayed in the column.</xs:documentation>

    </xs:annotation>

  </xs:element>

  <xs:element name="PropertyName" type="xs:string">

    <xs:annotation>

      <xs:documentation>Contains the name of the .NET object property that is displayed in the column.</xs:documentation>

    </xs:annotation>

  </xs:element>

  <xs:element name="NewLine">

    <xs:complexType/>

  </xs:element>

  <xs:element name="Name" type="xs:string">

    <xs:annotation>

      <xs:documentation>Contains the name of the view. This name is not displayed, but it can be used when referencing which view is used by an object.</xs:documentation>

    </xs:annotation>

  </xs:element>

  <xs:element name="ListItems">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:ListItem" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="ListItem">

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:PropertyName" minOccurs="0"/>

        <xs:element ref="psfd:Label" minOccurs="0"/>

        <xs:element ref="psfd:ScriptBlock" minOccurs="0"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="ListEntry">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:EntrySelectedBy" minOccurs="0"/>

        <xs:element ref="psfd:ListItems"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="ListEntries">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:ListEntry" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="ListControl">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:ListEntries"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="LeftIndent" type="xs:nonNegativeInteger"/>

  <xs:element name="Label" type="xs:string">

    <xs:annotation>

      <xs:documentation>Contains the label that appears at the top of the column.</xs:documentation>

    </xs:annotation>

  </xs:element>

  <xs:element name="GroupBy">

    <xs:annotation>

      <xs:documentation>Defines how Windows PowerShell groups the objects of the view. For example, a directory listing is grouped by its parent. Each grouping needs a header, as defined by a control node, such as a TableControl node. The header is most relevant when the user performs a recursive directory listing.</xs:documentation>

    </xs:annotation>

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:PropertyName" minOccurs="0"/>

        <xs:element ref="psfd:CustomControlName" minOccurs="0"/>

        <xs:element ref="psfd:Label" minOccurs="0"/>

        <xs:element ref="psfd:ScriptBlock" minOccurs="0"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="Frame">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:FirstLineHanging" minOccurs="0"/>

        <xs:element ref="psfd:LeftIndent" minOccurs="0"/>

        <xs:element ref="psfd:CustomItem"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="FormatString" type="xs:string"/>

  <xs:element name="ExpressionBinding">

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:ScriptBlock" minOccurs="0"/>

        <xs:element ref="psfd:PropertyName" minOccurs="0"/>

        <xs:element ref="psfd:ItemSelectionCondition" minOccurs="0"/>

        <xs:element ref="psfd:CustomControl" minOccurs="0"/>

        <xs:element ref="psfd:CustomControlName" minOccurs="0"/>

        <xs:element ref="psfd:EnumerateCollection" minOccurs="0"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="EntrySelectedBy">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:TypeName"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="CustomItem">

    <xs:complexType mixed="true">

      <xs:choice maxOccurs="unbounded">

        <xs:element ref="psfd:ExpressionBinding"/>

        <xs:element ref="psfd:NewLine"/>

        <xs:element ref="psfd:Frame"/>

        <xs:element ref="psfd:Text"/>

      </xs:choice>

    </xs:complexType>

  </xs:element>

  <xs:element name="CustomEntry">

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:CustomItem" minOccurs="0"/>

        <xs:element ref="psfd:EntrySelectedBy" minOccurs="0"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="CustomEntries">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:CustomEntry" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="CustomControlName" type="xs:string"/>

  <xs:element name="CustomControl">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:CustomEntries"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="Controls">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:Control" maxOccurs="unbounded"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="Control">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="psfd:Name"/>

        <xs:element ref="psfd:CustomControl"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

  <xs:element name="Configuration">

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:SelectionSets" minOccurs="0"/>

        <xs:element ref="psfd:Controls" minOccurs="0"/>

        <xs:element ref="psfd:ViewDefinitions"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="Alignment" type="xs:string">

    <xs:annotation>

      <xs:documentation>Contains the alignment setting (Left, Centered, Right) that controls how the data is displayed in the column.

</xs:documentation>

    </xs:annotation>

  </xs:element>

  <xs:element name="AutoSize"/>

  <xs:element name="OutOfBand"/>

  <xs:element name="FirstLineHanging" type="xs:nonNegativeInteger"/>

  <xs:element name="ItemSelectionCondition">

    <xs:complexType>

      <xs:all>

        <xs:element ref="psfd:ScriptBlock"/>

      </xs:all>

    </xs:complexType>

  </xs:element>

  <xs:element name="EnumerateCollection"/>

</xs:schema>

Labels:


Digg! del.icio.us
(1) comments

This page is powered by Blogger. Isn't yours?

LICENSE