问:
Not able to convert .xsd to .cs using xsd.exe command. It generates empty class
I have following schema. I am trying to convert it into a .cs file. Is there any workaround. I have tried it using xsd.exe command from Visual Studio Command prompt.</p>

```<code>  <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="mfp:anaf:dgti:f3000:declaratie:v1" targetNamespace="mfp:anaf:dgti:f3000:declaratie:v1" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.02" xml:lang="ro">
        <xs:element name="F3000" type="F3000Type"/>
        <xs:complexType name="F3000Type">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="inregistrare" type="InregistrareType" minOccurs="0" maxOccurs="300000"/>
                        <xs:element name="poolReport" type="PoolReportType" minOccurs="0" maxOccurs="300000"/>
                    </xs:sequence>
                    <xs:attribute name="luna" type="IntInt12_12SType" use="required"/>
                    <xs:attribute name="an" type="IntInt2014_2100SType" use="required"/>
                    <xs:attribute name="cui" type="CuiSType" use="required"/>
                    <xs:attribute name="giin" type="Str20"/>
                    <xs:attribute name="denumire" type="Str200" use="required"/>
                    <xs:attribute name="nume_declar" type="Str75" use="required"/>
                    <xs:attribute name="prenume_declar" type="Str75" use="required"/>
                    <xs:attribute name="functie_declar" type="Str75" use="required"/>
                    <xs:attribute name="totalPlata_A" type="IntPoz15SType" use="required"/>
                    <xs:attribute name="exista" type="IntPoz1SType"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="InregistrareType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="persoane" type="PersoaneType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="cont" type="ContType" minOccurs="0"/>
                        <xs:element name="sponsored" type="SponsoredType" minOccurs="0" maxOccurs="1"/>
                    </xs:sequence>
                    <xs:attribute name="d_rec1" type="IntInt1_2SType"/>
                    <xs:attribute name="id_inreg" type="IntPoz15SType" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="PersoaneType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="tin" type="TinType" maxOccurs="unbounded"/>
                        <xs:element name="rezidenta" type="RezidentaType" maxOccurs="unbounded"/>
                        <xs:element name="nationalitate" type="NationalitateType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="adresa" type="AdresaType" maxOccurs="unbounded"/>
                        <xs:element name="denumire" type="DenumireType" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="tip_declar" type="IntInt1_3SType" use="required"/>
                    <xs:attribute name="tip_ctr" type="Str_listaTipCtrSType"/>
                    <xs:attribute name="tip_pers" type="IntInt1_8SType"/>
                    <xs:attribute name="alt_tip_pers" type="Str50"/>
                    <xs:attribute name="tip_detinator_cont" type="Str_listaTipDetinatorSType"/>
                    <xs:attribute name="data_nastere" type="Str10"/>
                    <xs:attribute name="oras_nastere" type="Str100"/>
                    <xs:attribute name="sub_oras_nastere" type="Str100"/>
                    <xs:attribute name="cod_tara_nastere" type="IntPoz3SType"/>
                    <xs:attribute name="fost_nume_tara" type="Str100"/>
                    <xs:attribute name="cui_pers" type="CifSType"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="TinType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_in" type="Str50"/>
                    <xs:attribute name="cod_tara" type="IntPoz3SType" use="required"/>
                    <xs:attribute name="identif" type="Str50" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="RezidentaType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="indiciu" type="IntInt1_4SType"/>
                    <xs:attribute name="detalii_indiciu" type="Str75"/>
                    <xs:attribute name="cod_tara_rez" type="IntPoz3SType" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="NationalitateType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="nationalitate" type="Str3" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="AdresaType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_adresa" type="Str7"/>
                    <xs:attribute name="cod_tara_adresa" type="IntPoz3SType" use="required"/>
                    <xs:attribute name="adresa_free" type="Str200"/>
                    <xs:attribute name="strada" type="Str75"/>
                    <xs:attribute name="bloc" type="Str50"/>
                    <xs:attribute name="ap" type="Str50"/>
                    <xs:attribute name="etaj" type="Str50"/>
                    <xs:attribute name="nume_district" type="Str75"/>
                    <xs:attribute name="pob" type="Str10"/>
                    <xs:attribute name="cod_postal" type="Str10"/>
                    <xs:attribute name="oras" type="Str75" use="required"/>
                    <xs:attribute name="sub_tara" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="DenumireType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="titlu" type="TitluType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="generatie" type="GeneratieType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="sufix" type="SufixType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="mijl" type="MijlType" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="tip_nume" type="Str7"/>
                    <xs:attribute name="gen" type="Str1"/>
                    <xs:attribute name="denumire" type="Str200"/>
                    <xs:attribute name="titlu_prec" type="Str75"/>
                    <xs:attribute name="suf_general" type="Str75"/>
                    <xs:attribute name="nume1" type="Str75"/>
                    <xs:attribute name="tip_nume1" type="Str50"/>
                    <xs:attribute name="nume2" type="Str75"/>
                    <xs:attribute name="tip_nume2" type="Str50"/>
                    <xs:attribute name="tip_prefix" type="Str75"/>
                    <xs:attribute name="prefix" type="Str75"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="TitluType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="titlu" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="GeneratieType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="identificator" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="SufixType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="suf" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="MijlType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_nume_mij" type="Str75"/>
                    <xs:attribute name="nume_mij" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="ContType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="plati" type="PlatiType" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="id_cont" type="Str30" use="required"/>
                    <xs:attribute name="tip_numar_cont" type="Str7" use="required"/>
                    <xs:attribute name="det_cont" type="Str75"/>
                    <xs:attribute name="swift" type="Str8"/>
                    <xs:attribute name="nr_cont" type="Str50" use="required"/>
                    <xs:attribute name="tip_cont" type="IntInt1_6SType" use="required"/>
                    <xs:attribute name="trat_cont" type="Str6"/>
                    <xs:attribute name="autocertificare" type="IntInt0_1SType" use="required"/>
                    <xs:attribute name="cont_inchis" type="IntInt0_1SType"/>
                    <xs:attribute name="cont_nedocumentat" type="IntInt0_1SType"/>
                    <xs:attribute name="cont_inactiv" type="IntInt0_1SType"/>
                    <xs:attribute name="valoare_sold" type="DblPoz15_2SType"/>
                    <xs:attribute name="data_sold" type="DateSType" use="required"/>
                    <xs:attribute name="moneda_sold" type="Str3" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="PlatiType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_suma" type="IntInt1_7SType" use="required"/>
                    <xs:attribute name="detalii_plata" type="Str50"/>
                    <xs:attribute name="tax_rate" type="DblPoz2_2SType"/>
                    <xs:attribute name="suma" type="DblPoz15_2SType"/>
                    <xs:attribute name="data" type="DateSType" use="required"/>
                    <xs:attribute name="moneda_plata" type="Str3" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="SponsoredType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="rezidentaS" type="RezidentaSType" maxOccurs="unbounded"/>
                        <xs:element name="adresaS" type="AdresaType" maxOccurs="unbounded"/>
                        <xs:element name="denumireS" type="DenumireSType" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="tip_entitate" type="IntInt1_2SType" use="required"/>
                    <xs:attribute name="identif" type="Str50" use="required"/>
                    <xs:attribute name="cui" type="CuiSType"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="PoolReportType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="sold" type="SoldType" maxOccurs="unbounded"/>
                        <xs:element name="sponsored" type="SponsoredType" maxOccurs="1"/>
                    </xs:sequence>
                    <xs:attribute name="d_rec1" type="IntInt1_2SType"/>
                    <xs:attribute name="id_inreg" type="IntPoz15SType" use="required"/>
                    <xs:attribute name="tip_detinator" type="Str8"/>
                    <xs:attribute name="nr_conturi" type="IntPoz15SType"/>
                    <xs:attribute name="balanta" type="DblPoz15_2SType"/>
                    <xs:attribute name="moneda" type="Str3"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="SoldType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="val_sold" type="DblPoz15_2SType" use="required"/>
                    <xs:attribute name="moneda_sold" type="Str3" use="required"/>
                    <xs:attribute name="data_sold" type="DateSType" use="required"/>
                    <xs:attribute name="tip_detalii" type="Str200"/>
                    <xs:attribute name="detalii" type="Str200"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="RezidentaSType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="cod_tara_rez" type="IntPoz3SType" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="DenumireSType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_nume" type="Str7"/>
                    <xs:attribute name="denumire" type="Str200" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:simpleType name="IntInt12_12SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="12"/>
                <xs:maxInclusive value="12"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt2014_2100SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="2014"/>
                <xs:maxInclusive value="2100"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="CuiSType">
            <xs:restriction base="xs:token">
                <xs:pattern value="[1-9]\d{1,9}"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str20">
            <xs:restriction base="xs:string">
                <xs:maxLength value="20"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="CifSType">
            <xs:restriction base="xs:token">
                <xs:pattern value="[1-9]\d{12}|[1-9]\d{1,9}"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str25">
            <xs:restriction base="xs:string">
                <xs:maxLength value="25"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str200">
            <xs:restriction base="xs:string">
                <xs:maxLength value="200"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str75">
            <xs:restriction base="xs:string">
                <xs:maxLength value="75"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz15SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="999999999999999"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz3SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="999"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz1SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="9"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_2SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="2"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_3SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="3"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str_listaTipCtrSType">
            <xs:restriction base="xs:string">
                <xs:maxLength value="256"/>
                <xs:enumeration value="CRS801"/>
                <xs:enumeration value="CRS802"/>
                <xs:enumeration value="CRS803"/>
                <xs:enumeration value="CRS804"/>
                <xs:enumeration value="CRS805"/>
                <xs:enumeration value="CRS806"/>
                <xs:enumeration value="CRS807"/>
                <xs:enumeration value="CRS808"/>
                <xs:enumeration value="CRS809"/>
                <xs:enumeration value="CRS810"/>
                <xs:enumeration value="CRS811"/>
                <xs:enumeration value="CRS812"/>
                <xs:enumeration value="CRS813"/>
                <xs:enumeration value="CRS819"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_8SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="8"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str50">
            <xs:restriction base="xs:string">
                <xs:maxLength value="50"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str_listaTipDetinatorSType">
            <xs:restriction base="xs:string">
                <xs:maxLength value="256"/>
                <xs:enumeration value="CRS101"/>
                <xs:enumeration value="CRS102"/>
                <xs:enumeration value="CRS103"/>
                <xs:enumeration value="FATCA101"/>
                <xs:enumeration value="FATCA102"/>
                <xs:enumeration value="FATCA103"/>
                <xs:enumeration value="FATCA104"/>
                <xs:enumeration value="FATCA105"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str10">
            <xs:restriction base="xs:string">
                <xs:maxLength value="10"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str100">
            <xs:restriction base="xs:string">
                <xs:maxLength value="100"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str2">
            <xs:restriction base="xs:string">
                <xs:maxLength value="2"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str3">
            <xs:restriction base="xs:string">
                <xs:maxLength value="3"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_4SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="4"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str7">
            <xs:restriction base="xs:string">
                <xs:maxLength value="7"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str1">
            <xs:restriction base="xs:string">
                <xs:maxLength value="1"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str8">
            <xs:restriction base="xs:string">
                <xs:maxLength value="8"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_7SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="7"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_6SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="6"/>
            </xs:restriction>
        </xs:simpleType>

        <xs:simpleType name="Str30">
            <xs:restriction base="xs:string">
                <xs:maxLength value="30"/>
            </xs:restriction>
        </xs:simpleType>

        <xs:simpleType name="Str6">
            <xs:restriction base="xs:string">
                <xs:maxLength value="6"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt0_1SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="1"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="DateSType">
            <xs:restriction base="xs:token">
                <xs:pattern value="([1-9]|0[1-9]|[12][0-9]|3[01])\.([1-9]|0[1-9]|1[012])\.\d{4}"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="DblPoz15_2SType">
            <xs:restriction base="xs:double">
                <xs:minInclusive value="0."/>
                <xs:pattern value="\d{0,15}(\.\d{0,2})?"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="DblPoz2_2SType">
            <xs:restriction base="xs:double">
                <xs:minInclusive value="0."/>
                <xs:pattern value="\d{0,2}(\.\d{0,2})?"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz2SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="99"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:schema>
</code>```

<p>When I run xsd.exe command, it generates following empty class.</p>

```<code>//--------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System.Xml.Serialization;

//
// This source code was auto-generated by xsd, Version=4.0.30319.17929.
//

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="mfp:anaf:dgti:f3000:declaratie:v1")]
[System.Xml.Serialization.XmlRootAttribute("F3000", Namespace="mfp:anaf:dgti:f3000:declaratie:v1", IsNullable=false)]
public partial class F3000Type {
}
</code>```

答:
Following elements were not letting xsd.exe generate complete .cs file.

```<code><xs:complexContent>
                <xs:restriction base="xs:anyType">
                  .
                  .
                  .
                </xs:restriction>
</xs:complexContent>
</code>```

On removing these tags, it generated the output .cs file. I still do not understand why, but this helped.

Body:
I have following schema. I am trying to convert it into a .cs file. Is there any workaround. I have tried it using xsd.exe command from Visual Studio Command prompt.

  <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="mfp:anaf:dgti:f3000:declaratie:v1" targetNamespace="mfp:anaf:dgti:f3000:declaratie:v1" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.02" xml:lang="ro">
        <xs:element name="F3000" type="F3000Type"/>
        <xs:complexType name="F3000Type">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="inregistrare" type="InregistrareType" minOccurs="0" maxOccurs="300000"/>
                        <xs:element name="poolReport" type="PoolReportType" minOccurs="0" maxOccurs="300000"/>
                    </xs:sequence>
                    <xs:attribute name="luna" type="IntInt12_12SType" use="required"/>
                    <xs:attribute name="an" type="IntInt2014_2100SType" use="required"/>
                    <xs:attribute name="cui" type="CuiSType" use="required"/>
                    <xs:attribute name="giin" type="Str20"/>
                    <xs:attribute name="denumire" type="Str200" use="required"/>
                    <xs:attribute name="nume_declar" type="Str75" use="required"/>
                    <xs:attribute name="prenume_declar" type="Str75" use="required"/>
                    <xs:attribute name="functie_declar" type="Str75" use="required"/>
                    <xs:attribute name="totalPlata_A" type="IntPoz15SType" use="required"/>
                    <xs:attribute name="exista" type="IntPoz1SType"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="InregistrareType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="persoane" type="PersoaneType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="cont" type="ContType" minOccurs="0"/>
                        <xs:element name="sponsored" type="SponsoredType" minOccurs="0" maxOccurs="1"/>
                    </xs:sequence>
                    <xs:attribute name="d_rec1" type="IntInt1_2SType"/>
                    <xs:attribute name="id_inreg" type="IntPoz15SType" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="PersoaneType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="tin" type="TinType" maxOccurs="unbounded"/>
                        <xs:element name="rezidenta" type="RezidentaType" maxOccurs="unbounded"/>
                        <xs:element name="nationalitate" type="NationalitateType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="adresa" type="AdresaType" maxOccurs="unbounded"/>
                        <xs:element name="denumire" type="DenumireType" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="tip_declar" type="IntInt1_3SType" use="required"/>
                    <xs:attribute name="tip_ctr" type="Str_listaTipCtrSType"/>
                    <xs:attribute name="tip_pers" type="IntInt1_8SType"/>
                    <xs:attribute name="alt_tip_pers" type="Str50"/>
                    <xs:attribute name="tip_detinator_cont" type="Str_listaTipDetinatorSType"/>
                    <xs:attribute name="data_nastere" type="Str10"/>
                    <xs:attribute name="oras_nastere" type="Str100"/>
                    <xs:attribute name="sub_oras_nastere" type="Str100"/>
                    <xs:attribute name="cod_tara_nastere" type="IntPoz3SType"/>
                    <xs:attribute name="fost_nume_tara" type="Str100"/>
                    <xs:attribute name="cui_pers" type="CifSType"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="TinType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_in" type="Str50"/>
                    <xs:attribute name="cod_tara" type="IntPoz3SType" use="required"/>
                    <xs:attribute name="identif" type="Str50" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="RezidentaType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="indiciu" type="IntInt1_4SType"/>
                    <xs:attribute name="detalii_indiciu" type="Str75"/>
                    <xs:attribute name="cod_tara_rez" type="IntPoz3SType" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="NationalitateType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="nationalitate" type="Str3" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="AdresaType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_adresa" type="Str7"/>
                    <xs:attribute name="cod_tara_adresa" type="IntPoz3SType" use="required"/>
                    <xs:attribute name="adresa_free" type="Str200"/>
                    <xs:attribute name="strada" type="Str75"/>
                    <xs:attribute name="bloc" type="Str50"/>
                    <xs:attribute name="ap" type="Str50"/>
                    <xs:attribute name="etaj" type="Str50"/>
                    <xs:attribute name="nume_district" type="Str75"/>
                    <xs:attribute name="pob" type="Str10"/>
                    <xs:attribute name="cod_postal" type="Str10"/>
                    <xs:attribute name="oras" type="Str75" use="required"/>
                    <xs:attribute name="sub_tara" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="DenumireType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="titlu" type="TitluType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="generatie" type="GeneratieType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="sufix" type="SufixType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="mijl" type="MijlType" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="tip_nume" type="Str7"/>
                    <xs:attribute name="gen" type="Str1"/>
                    <xs:attribute name="denumire" type="Str200"/>
                    <xs:attribute name="titlu_prec" type="Str75"/>
                    <xs:attribute name="suf_general" type="Str75"/>
                    <xs:attribute name="nume1" type="Str75"/>
                    <xs:attribute name="tip_nume1" type="Str50"/>
                    <xs:attribute name="nume2" type="Str75"/>
                    <xs:attribute name="tip_nume2" type="Str50"/>
                    <xs:attribute name="tip_prefix" type="Str75"/>
                    <xs:attribute name="prefix" type="Str75"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="TitluType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="titlu" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="GeneratieType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="identificator" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="SufixType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="suf" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="MijlType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_nume_mij" type="Str75"/>
                    <xs:attribute name="nume_mij" type="Str75" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="ContType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="plati" type="PlatiType" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="id_cont" type="Str30" use="required"/>
                    <xs:attribute name="tip_numar_cont" type="Str7" use="required"/>
                    <xs:attribute name="det_cont" type="Str75"/>
                    <xs:attribute name="swift" type="Str8"/>
                    <xs:attribute name="nr_cont" type="Str50" use="required"/>
                    <xs:attribute name="tip_cont" type="IntInt1_6SType" use="required"/>
                    <xs:attribute name="trat_cont" type="Str6"/>
                    <xs:attribute name="autocertificare" type="IntInt0_1SType" use="required"/>
                    <xs:attribute name="cont_inchis" type="IntInt0_1SType"/>
                    <xs:attribute name="cont_nedocumentat" type="IntInt0_1SType"/>
                    <xs:attribute name="cont_inactiv" type="IntInt0_1SType"/>
                    <xs:attribute name="valoare_sold" type="DblPoz15_2SType"/>
                    <xs:attribute name="data_sold" type="DateSType" use="required"/>
                    <xs:attribute name="moneda_sold" type="Str3" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="PlatiType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_suma" type="IntInt1_7SType" use="required"/>
                    <xs:attribute name="detalii_plata" type="Str50"/>
                    <xs:attribute name="tax_rate" type="DblPoz2_2SType"/>
                    <xs:attribute name="suma" type="DblPoz15_2SType"/>
                    <xs:attribute name="data" type="DateSType" use="required"/>
                    <xs:attribute name="moneda_plata" type="Str3" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="SponsoredType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="rezidentaS" type="RezidentaSType" maxOccurs="unbounded"/>
                        <xs:element name="adresaS" type="AdresaType" maxOccurs="unbounded"/>
                        <xs:element name="denumireS" type="DenumireSType" maxOccurs="unbounded"/>
                    </xs:sequence>
                    <xs:attribute name="tip_entitate" type="IntInt1_2SType" use="required"/>
                    <xs:attribute name="identif" type="Str50" use="required"/>
                    <xs:attribute name="cui" type="CuiSType"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="PoolReportType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:sequence>
                        <xs:element name="sold" type="SoldType" maxOccurs="unbounded"/>
                        <xs:element name="sponsored" type="SponsoredType" maxOccurs="1"/>
                    </xs:sequence>
                    <xs:attribute name="d_rec1" type="IntInt1_2SType"/>
                    <xs:attribute name="id_inreg" type="IntPoz15SType" use="required"/>
                    <xs:attribute name="tip_detinator" type="Str8"/>
                    <xs:attribute name="nr_conturi" type="IntPoz15SType"/>
                    <xs:attribute name="balanta" type="DblPoz15_2SType"/>
                    <xs:attribute name="moneda" type="Str3"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="SoldType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="val_sold" type="DblPoz15_2SType" use="required"/>
                    <xs:attribute name="moneda_sold" type="Str3" use="required"/>
                    <xs:attribute name="data_sold" type="DateSType" use="required"/>
                    <xs:attribute name="tip_detalii" type="Str200"/>
                    <xs:attribute name="detalii" type="Str200"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="RezidentaSType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="cod_tara_rez" type="IntPoz3SType" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="DenumireSType">
            <xs:complexContent>
                <xs:restriction base="xs:anyType">
                    <xs:attribute name="tip_nume" type="Str7"/>
                    <xs:attribute name="denumire" type="Str200" use="required"/>
                </xs:restriction>
            </xs:complexContent>
        </xs:complexType>
        <xs:simpleType name="IntInt12_12SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="12"/>
                <xs:maxInclusive value="12"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt2014_2100SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="2014"/>
                <xs:maxInclusive value="2100"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="CuiSType">
            <xs:restriction base="xs:token">
                <xs:pattern value="[1-9]\d{1,9}"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str20">
            <xs:restriction base="xs:string">
                <xs:maxLength value="20"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="CifSType">
            <xs:restriction base="xs:token">
                <xs:pattern value="[1-9]\d{12}|[1-9]\d{1,9}"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str25">
            <xs:restriction base="xs:string">
                <xs:maxLength value="25"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str200">
            <xs:restriction base="xs:string">
                <xs:maxLength value="200"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str75">
            <xs:restriction base="xs:string">
                <xs:maxLength value="75"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz15SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="999999999999999"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz3SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="999"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz1SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="9"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_2SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="2"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_3SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="3"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str_listaTipCtrSType">
            <xs:restriction base="xs:string">
                <xs:maxLength value="256"/>
                <xs:enumeration value="CRS801"/>
                <xs:enumeration value="CRS802"/>
                <xs:enumeration value="CRS803"/>
                <xs:enumeration value="CRS804"/>
                <xs:enumeration value="CRS805"/>
                <xs:enumeration value="CRS806"/>
                <xs:enumeration value="CRS807"/>
                <xs:enumeration value="CRS808"/>
                <xs:enumeration value="CRS809"/>
                <xs:enumeration value="CRS810"/>
                <xs:enumeration value="CRS811"/>
                <xs:enumeration value="CRS812"/>
                <xs:enumeration value="CRS813"/>
                <xs:enumeration value="CRS819"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_8SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="8"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str50">
            <xs:restriction base="xs:string">
                <xs:maxLength value="50"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str_listaTipDetinatorSType">
            <xs:restriction base="xs:string">
                <xs:maxLength value="256"/>
                <xs:enumeration value="CRS101"/>
                <xs:enumeration value="CRS102"/>
                <xs:enumeration value="CRS103"/>
                <xs:enumeration value="FATCA101"/>
                <xs:enumeration value="FATCA102"/>
                <xs:enumeration value="FATCA103"/>
                <xs:enumeration value="FATCA104"/>
                <xs:enumeration value="FATCA105"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str10">
            <xs:restriction base="xs:string">
                <xs:maxLength value="10"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str100">
            <xs:restriction base="xs:string">
                <xs:maxLength value="100"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str2">
            <xs:restriction base="xs:string">
                <xs:maxLength value="2"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str3">
            <xs:restriction base="xs:string">
                <xs:maxLength value="3"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_4SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="4"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str7">
            <xs:restriction base="xs:string">
                <xs:maxLength value="7"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str1">
            <xs:restriction base="xs:string">
                <xs:maxLength value="1"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Str8">
            <xs:restriction base="xs:string">
                <xs:maxLength value="8"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_7SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="7"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt1_6SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="6"/>
            </xs:restriction>
        </xs:simpleType>

        <xs:simpleType name="Str30">
            <xs:restriction base="xs:string">
                <xs:maxLength value="30"/>
            </xs:restriction>
        </xs:simpleType>

        <xs:simpleType name="Str6">
            <xs:restriction base="xs:string">
                <xs:maxLength value="6"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntInt0_1SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="1"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="DateSType">
            <xs:restriction base="xs:token">
                <xs:pattern value="([1-9]|0[1-9]|[12][0-9]|3[01])\.([1-9]|0[1-9]|1[012])\.\d{4}"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="DblPoz15_2SType">
            <xs:restriction base="xs:double">
                <xs:minInclusive value="0."/>
                <xs:pattern value="\d{0,15}(\.\d{0,2})?"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="DblPoz2_2SType">
            <xs:restriction base="xs:double">
                <xs:minInclusive value="0."/>
                <xs:pattern value="\d{0,2}(\.\d{0,2})?"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="IntPoz2SType">
            <xs:restriction base="xs:integer">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="99"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:schema>

When I run xsd.exe command, it generates following empty class.

//--------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System.Xml.Serialization;

//
// This source code was auto-generated by xsd, Version=4.0.30319.17929.
//

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="mfp:anaf:dgti:f3000:declaratie:v1")]
[System.Xml.Serialization.XmlRootAttribute("F3000", Namespace="mfp:anaf:dgti:f3000:declaratie:v1", IsNullable=false)]
public partial class F3000Type {
}

Body:
Following elements were not letting xsd.exe generate complete .cs file.

<xs:complexContent>
                <xs:restriction base="xs:anyType">
                  .
                  .
                  .
                </xs:restriction>
</xs:complexContent>

On removing these tags, it generated the output .cs file. I still do not understand why, but this helped.


来源: stackexchange

问:
Anisotropic zooming in d3 version 4
How can one provide separate zoom scales for x- and y-axis in D3 version 4?

This example by Patrick Brockman gave a method that worked wonderfully under v3, which allowed binding zooming to scale-factor objects.  The relevant code:

```<code>  xyzoom = d3.behavior.zoom()
    .x(xscale)
    .y(yscale)
    .on("zoom", zoomable ? draw : null);
  xzoom = d3.behavior.zoom()
    .x(xscale)
    .on("zoom", zoomable ? draw : null);
  yzoom = d3.behavior.zoom()
    .y(yscale)
    .on("zoom", zoomable ? draw : null);
</code>```

Note that there are two scaling objects, one for each axis, and they are bound from both the axis label/ticks area and the main plot, so that pan/zoom activities are cumulative across all three areas.

In the new paradigm, there's a zoom-transform object linked with page elements where the zooming takes place, which has a single scale factor and two-dimensional offset.  The support for affecting scaling objects transforms the transform without updating it in-place.  Sharing a zoom transform between all three areas would give only one scale factor overall (not to mention the problem that zooming in an axis label/tick area would still affect the other axis), and allowing each to have its own zoom transform creates a horrible problem with order of application (transform multiplication is NOT commutative).

There doesn't even seem to be a straightforward way to get the transform for individual steps and combine them myself (trying to reset the zoom transform to identity raises all the same events as user actions).

How can one achieve anisotropic zoom (different stretch factors in different directions) in version 4?

Here's what I have so far, which is totally wrong (it accumulates the effect of a zoom transform which itself is cumulative of zoom events):

```<code>function zoom_update() {
  svg.select('rect.zoom.x.box').call(d3.zoom().on('zoom', function() {
              xscale = d3.event.transform.rescaleX(xscale);
              update();
         }));
  svg.select('rect.zoom.y.box').call(d3.zoom().on('zoom', function() {
              yscale = d3.event.transform.rescaleY(yscale);
              update();
         }));
  svg.select('rect.zoom.xy.box').call(d3.zoom().on('zoom', function() {
              xscale = d3.event.transform.rescaleX(xscale);
              yscale = d3.event.transform.rescaleY(yscale);
              update();
         }));
</code>```

Is it necessary to skip over the zoom module and process mouse events directly?

答:
Take a look to this example

For your case, I'd suggest something like

```<code>// define the zoom
d3.zoom().on('zoom', function() {
    zoom_update();
});

function zoom_update() {
    // re-scale
    svg.select('rect.zoom.x.box')
        .call(xAxis.scale(d3.event.transform.rescaleX(x)));
    svg.select('rect.zoom.y.box')
        .call(yAxis.scale(d3.event.transform.rescaleY(y)));

    svg.select('rect.zoom.xy.box')
        .call(xAxis.scale(d3.event.transform.rescaleX(x)));
    svg.select('rect.zoom.xy.box')
        .call(yAxis.scale(d3.event.transform.rescaleY(y)));

    update();
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Anisotropic zooming in d3 version 4

Body:
How can one provide separate zoom scales for x- and y-axis in D3 version 4?

This example by Patrick Brockman gave a method that worked wonderfully under v3, which allowed binding zooming to scale-factor objects.  The relevant code:

  xyzoom = d3.behavior.zoom()
    .x(xscale)
    .y(yscale)
    .on("zoom", zoomable ? draw : null);
  xzoom = d3.behavior.zoom()
    .x(xscale)
    .on("zoom", zoomable ? draw : null);
  yzoom = d3.behavior.zoom()
    .y(yscale)
    .on("zoom", zoomable ? draw : null);

Note that there are two scaling objects, one for each axis, and they are bound from both the axis label/ticks area and the main plot, so that pan/zoom activities are cumulative across all three areas.

In the new paradigm, there's a zoom-transform object linked with page elements where the zooming takes place, which has a single scale factor and two-dimensional offset.  The support for affecting scaling objects transforms the transform without updating it in-place.  Sharing a zoom transform between all three areas would give only one scale factor overall (not to mention the problem that zooming in an axis label/tick area would still affect the other axis), and allowing each to have its own zoom transform creates a horrible problem with order of application (transform multiplication is NOT commutative).

There doesn't even seem to be a straightforward way to get the transform for individual steps and combine them myself (trying to reset the zoom transform to identity raises all the same events as user actions).

How can one achieve anisotropic zoom (different stretch factors in different directions) in version 4?

Here's what I have so far, which is totally wrong (it accumulates the effect of a zoom transform which itself is cumulative of zoom events):

function zoom_update() {
  svg.select('rect.zoom.x.box').call(d3.zoom().on('zoom', function() {
              xscale = d3.event.transform.rescaleX(xscale);
              update();
         }));
  svg.select('rect.zoom.y.box').call(d3.zoom().on('zoom', function() {
              yscale = d3.event.transform.rescaleY(yscale);
              update();
         }));
  svg.select('rect.zoom.xy.box').call(d3.zoom().on('zoom', function() {
              xscale = d3.event.transform.rescaleX(xscale);
              yscale = d3.event.transform.rescaleY(yscale);
              update();
         }));

Is it necessary to skip over the zoom module and process mouse events directly?

Body:
Take a look to this example

For your case, I'd suggest something like

// define the zoom
d3.zoom().on('zoom', function() {
    zoom_update();
});

function zoom_update() {
    // re-scale
    svg.select('rect.zoom.x.box')
        .call(xAxis.scale(d3.event.transform.rescaleX(x)));
    svg.select('rect.zoom.y.box')
        .call(yAxis.scale(d3.event.transform.rescaleY(y)));

    svg.select('rect.zoom.xy.box')
        .call(xAxis.scale(d3.event.transform.rescaleX(x)));
    svg.select('rect.zoom.xy.box')
        .call(yAxis.scale(d3.event.transform.rescaleY(y)));

    update();
}


问:
Android orientation change losing data solution not working
I have been looking for an solution on how to make my app not to loose data when orientation of phone changes. I have found one and it is adding this line of code

```<code>android:configChanges="orientation|keyboardHidden">
</code>```

to android manifest. So i did it:

```<code><?xml version="1.0" encoding="utf-8"?>
</code>```

```<code><application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
        android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
</code>```

And my data still get lost when orientation changes, could anyone please help me ? Thank you very much.

My java code:

```<code>public class MainActivity extends AppCompatActivity {
int scoreofShooter1 = 0;
int scoreofShooter2 = 0;

@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public void addOneForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 1;
    displayForShooter1(scoreofShooter1);
}

public void addTwoForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 2;
    displayForShooter1(scoreofShooter1);
}
public void addThreeForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 3;
    displayForShooter1(scoreofShooter1);
}

public void addFourForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 4;
    displayForShooter1(scoreofShooter1);
}

public void addOneForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 1;
    displayForShooter2(scoreofShooter2);
}

public void addTwoForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 2;
    displayForShooter2(scoreofShooter2);
}
public void addThreeForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 3;
    displayForShooter2(scoreofShooter2);
}

public void addFourForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 4;
    displayForShooter2(scoreofShooter2);
}

public void resetScoreOfShooter1(View view) {
    scoreofShooter1 = 0;
    displayForShooter1(scoreofShooter1);
}

public void resetScoreOfShooter2(View view) {
    scoreofShooter2 = 0;
    displayForShooter2(scoreofShooter2);
}

public void displayForShooter1(int score) {
    TextView scoreView = (TextView) findViewById(R.id.shooter_1_score);
    scoreView.setText(String.valueOf(score));
}

public void displayForShooter2(int score) {
    TextView scoreView = (TextView) findViewById(R.id.shooter_2_score);
    scoreView.setText(String.valueOf(score));
}
</code>```

}

答:
Change this:

```<code>android:configChanges="orientation|keyboardHidden">
</code>```

to:

```<code>android:configChanges="orientation|keyboardHidden|screenSize">
</code>```

"orientation":
  The screen orientation has changed — the user has rotated
  the device.

Note: If your application targets API level 13 or higher (as declared
  by the minSdkVersion and targetSdkVersionattributes), then you should
  also declare the "screenSize" configuration, because it also changes
  when a device switches between portrait and landscape orientations.

Body:
I have been looking for an solution on how to make my app not to loose data when orientation of phone changes. I have found one and it is adding this line of code

android:configChanges="orientation|keyboardHidden">

to android manifest. So i did it:

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

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
        android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

And my data still get lost when orientation changes, could anyone please help me ? Thank you very much.

My java code:

public class MainActivity extends AppCompatActivity {
int scoreofShooter1 = 0;
int scoreofShooter2 = 0;

@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public void addOneForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 1;
    displayForShooter1(scoreofShooter1);
}

public void addTwoForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 2;
    displayForShooter1(scoreofShooter1);
}
public void addThreeForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 3;
    displayForShooter1(scoreofShooter1);
}

public void addFourForShooter1(View view) {
    scoreofShooter1 = scoreofShooter1 + 4;
    displayForShooter1(scoreofShooter1);
}

public void addOneForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 1;
    displayForShooter2(scoreofShooter2);
}

public void addTwoForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 2;
    displayForShooter2(scoreofShooter2);
}
public void addThreeForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 3;
    displayForShooter2(scoreofShooter2);
}

public void addFourForShooter2(View view) {
    scoreofShooter2 = scoreofShooter2 + 4;
    displayForShooter2(scoreofShooter2);
}

public void resetScoreOfShooter1(View view) {
    scoreofShooter1 = 0;
    displayForShooter1(scoreofShooter1);
}

public void resetScoreOfShooter2(View view) {
    scoreofShooter2 = 0;
    displayForShooter2(scoreofShooter2);
}

public void displayForShooter1(int score) {
    TextView scoreView = (TextView) findViewById(R.id.shooter_1_score);
    scoreView.setText(String.valueOf(score));
}

public void displayForShooter2(int score) {
    TextView scoreView = (TextView) findViewById(R.id.shooter_2_score);
    scoreView.setText(String.valueOf(score));
}

}

Body:
Change this:

android:configChanges="orientation|keyboardHidden">

to:

android:configChanges="orientation|keyboardHidden|screenSize">

"orientation":
  The screen orientation has changed — the user has rotated
  the device.

Note: If your application targets API level 13 or higher (as declared
  by the minSdkVersion and targetSdkVersionattributes), then you should
  also declare the "screenSize" configuration, because it also changes
  when a device switches between portrait and landscape orientations.


问:
Add headers h1, h2, h3 (Contempo)
Help I need to implement header H1, H2 and H3 correctly in blogspot theme "Contempo", issue just released a week ago, approx. March 20, 2017. (Tema contempo)

By default comes H3 for the title of the post

```<code><h3 class='post-title entry-title'>
   <b:if cond='data:post.link or (data:post.url and data:view.url != data:post.url)'>
      <a expr:href='data:post.link ?: data:post.url'><data:post.title/></a>
   <b:else/>
      <data:post.title/>
   </b:if>
</h3>
</code>```

And I need for better SEO to implement

H1 title of article
H2 internal subtitle of the article
H3 subtitle of article

I have implemented this code

```<code><b:if cond='data:blog.pageType == "index"'>
   <h2 class='post-title entry-title'>
     <b:if cond='data:post.link or (data:post.url and data:view.url != data:post.url)'>
       <a expr:href='data:post.link ?: data:post.url'><data:post.title/></a>
     <b:else/>
       <data:post.title/>
     </b:if>
   </h2>
<b:else/>
   <h1 class='post-title entry-title'><data:post.title/></h1>
</b:if>
</code>```

But I get:
H1 blog name
H1 article name

And I think there should not be 2 H1 in the home, so something is poorly implemented

Another thing the Contempo theme brings a prominent entry and this is shown in the home as H3

答:
You're right that the page should not contain two h1 elements.

Go to Header1 widget in your template and replace this:

```<code><b:include name='super.title'/>
</code>```

With:

```<code><b:if cond='data:view.isSingleItem'>
  <h2 class='title'>
    <a expr:href='data:blog.homepageUrl'>
      <data:title/>
    </a>
  </h2>
<b:else/>
  <h1 class='title'>
    <a expr:href='data:blog.homepageUrl'>
      <data:title/>
    </a>
  </h1>
</b:if>
</code>```

Title: Add headers h1, h2, h3 (Contempo)

Body:
Help I need to implement header H1, H2 and H3 correctly in blogspot theme "Contempo", issue just released a week ago, approx. March 20, 2017. (Tema contempo)

By default comes H3 for the title of the post

      <data:post.title/>

      <data:post.title/>

And I need for better SEO to implement

H1 title of article
H2 internal subtitle of the article
H3 subtitle of article

I have implemented this code

       <data:post.title/>

       <data:post.title/>

<data:post.title/>

But I get:
H1 blog name
H1 article name

And I think there should not be 2 H1 in the home, so something is poorly implemented

Another thing the Contempo theme brings a prominent entry and this is shown in the home as H3

Body:
You're right that the page should not contain two h1 elements.

Go to Header1 widget in your template and replace this:

<b:include name='super.title'/>

With:

<b:if cond='data:view.isSingleItem'>
  <h2 class='title'>
    <a expr:href='data:blog.homepageUrl'>
      <data:title/>
    </a>
  </h2>
<b:else/>
  <h1 class='title'>
    <a expr:href='data:blog.homepageUrl'>
      <data:title/>
    </a>
  </h1>
</b:if>

ContentLicense: CC BY-SA 4.0


问:
Identify the DataGrid from ItemCommand inside Repeater
I've a DataGrid inside a Repeater. In this DataGrid I've a Button "btnTest". How to identify which (Index of the Repeater) DataGrid from ItemCommand in DataGrid.

ASPX:

```<code><asp:Repeater ID="ProdList" OnItemDataBound="ProdList_ItemDataBound" OnItemCommand="ProdList_ItemCommand" runat="server">
    <ItemTemplate>
        <div style="padding: 5px;">
            <asp:DataGrid ID="dtg" OnItemDataBound="dtg_ItemDataBound" OnItemCommand="dtg_ItemCommand" runat="server" AutoGenerateColumns="False" DataSource='<%# DataBinder.Eval(Container.DataItem, "ProductItems") %>'>
                <Columns>
                    <asp:BoundColumn HeaderText="ProdName" DataField="ProdName"></asp:BoundColumn>
                    <asp:TemplateColumn>
                        <ItemTemplate>
                            <asp:Button ID="btnTest" runat="server" CommandName="Test" Text="Test" />
                        </ItemTemplate>
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>
            <asp:TextBox ID="txtSearch" runat="server" style="width:250px;" CssClass="txtSearch" autocomplete="off"></asp:TextBox>
            <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btnSearch" onclick="btnSearch_Click" />
            <asp:Button ID="btnCheckAvailability" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProdId") %>' CssClass="button" CommandName="CheckAvailability" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ProdId") %>' />
        </div>
    </ItemTemplate>
</asp:Repeater>
</code>```

ASPX.CS:

```<code>protected void ProdList_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {

    }
}

protected void ProdList_ItemCommand(Object Sender, RepeaterCommandEventArgs e)
{

}

protected void dtg_ItemDataBound(object sender, DataGridItemEventArgs e)
{

}

protected void dtg_ItemCommand(object source, DataGridCommandEventArgs e)
{
    // I want to identify DataGrid here
}
</code>```

Please help me.

答:
Could you please try this untested code in your "dtg_ItemCommand".</p>

```<code>protected void dtg_ItemCommand(object source, DataGridCommandEventArgs e)
{
    //Get the reference of the datagrid.
    DataGrid dg= (source as DataGrid);

    //Get the Repeater Item reference
    RepeaterItem item = dg.NamingContainer as RepeaterItem;

    //Get the repeater item index
    int index = item.ItemIndex;
}
</code>```

Body:
I've a DataGrid inside a Repeater. In this DataGrid I've a Button "btnTest". How to identify which (Index of the Repeater) DataGrid from ItemCommand in DataGrid.

ASPX:

<asp:Repeater ID="ProdList" OnItemDataBound="ProdList_ItemDataBound" OnItemCommand="ProdList_ItemCommand" runat="server">
    <ItemTemplate>

            <asp:DataGrid ID="dtg" OnItemDataBound="dtg_ItemDataBound" OnItemCommand="dtg_ItemCommand" runat="server" AutoGenerateColumns="False" DataSource='<%# DataBinder.Eval(Container.DataItem, "ProductItems") %>'>
                <Columns>
                    <asp:BoundColumn HeaderText="ProdName" DataField="ProdName"></asp:BoundColumn>
                    <asp:TemplateColumn>
                        <ItemTemplate>
                            <asp:Button ID="btnTest" runat="server" CommandName="Test" Text="Test" />
                        </ItemTemplate>
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>
            <asp:TextBox ID="txtSearch" runat="server" style="width:250px;" CssClass="txtSearch" autocomplete="off"></asp:TextBox>
            <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btnSearch" onclick="btnSearch_Click" />
            <asp:Button ID="btnCheckAvailability" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProdId") %>' CssClass="button" CommandName="CheckAvailability" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ProdId") %>' />

    </ItemTemplate>
</asp:Repeater>

ASPX.CS:

protected void ProdList_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {

    }
}

protected void ProdList_ItemCommand(Object Sender, RepeaterCommandEventArgs e)
{

}

protected void dtg_ItemDataBound(object sender, DataGridItemEventArgs e)
{

}

protected void dtg_ItemCommand(object source, DataGridCommandEventArgs e)
{
    // I want to identify DataGrid here
}

Please help me.

Body:
Could you please try this untested code in your "dtg_ItemCommand".

protected void dtg_ItemCommand(object source, DataGridCommandEventArgs e)
{
    //Get the reference of the datagrid.
    DataGrid dg= (source as DataGrid);

    //Get the Repeater Item reference
    RepeaterItem item = dg.NamingContainer as RepeaterItem;

    //Get the repeater item index
    int index = item.ItemIndex;
}


问:
Reverting a specific old commit
Hi I have a repository on Bitbucket. I am working with a partner on a project and he pushed some updates few commits ago, working on a file, I realized that he did wrong code. I want to revert that commit, particularly that file only so I can get back code of that file only. cartitems.blade.php

Is this possible?

Attached is the image of SourceTree tool. Uncommited changes are my new changes. I want to keep these and recover that specific file only.

答:
To revert only the cartitems.blade.php file (not the whole commit) you can checkout the version of the file before the "bad" commit:

```<code>git checkout 41123f6 -- resources/views/cart/cartitems.blade.php
</code>```

Now make sure no other files are staged for commit and commit the file:

```<code>git add resources/views/cart/cartitems.blade.php
git commit -m "Revert cartitems.blade.php"
</code>```

This way you won't have to rewrite history. I'm not sure if you could do this with the SourceTree GUI, however. You can use the "Terminal" button in the top right corner of SourceTree to open the terminal.

Title: Reverting a specific old commit

Body:
To revert only the cartitems.blade.php file (not the whole commit) you can checkout the version of the file before the "bad" commit:

git checkout 41123f6 -- resources/views/cart/cartitems.blade.php

Now make sure no other files are staged for commit and commit the file:

git add resources/views/cart/cartitems.blade.php
git commit -m "Revert cartitems.blade.php"

This way you won't have to rewrite history. I'm not sure if you could do this with the SourceTree GUI, however. You can use the "Terminal" button in the top right corner of SourceTree to open the terminal.


问:
What headers does App Engine Flex forward to your application?
It's not very well documented anywhere. Specifically, if I want to detect http vs https, how should I do that?</p>

答:
Here you go, with some names/IP addresses changed. You can use X-Forwarded-Proto to detect http vs https in App Engine Flex.

```<code>"X-Appengine-Region": "ca",
"X-Cloud-Trace-Context": "8b8613a90a389a6c1e125b330ab20b24/6635756377403605329",
"X-Appengine-Country": "US",
"X-Forwarded-Proto": "http",
"X-Appengine-Citylatlong": "23.774929,-120.419416",
"X-Appengine-City": "city name",
"Via": "1.1 google",
"X-Forwarded-For": "1.2.3.4, 5.6.7.8"
</code>```

Body:
Here you go, with some names/IP addresses changed. You can use X-Forwarded-Proto to detect http vs https in App Engine Flex.

"X-Appengine-Region": "ca",
"X-Cloud-Trace-Context": "8b8613a90a389a6c1e125b330ab20b24/6635756377403605329",
"X-Appengine-Country": "US",
"X-Forwarded-Proto": "http",
"X-Appengine-Citylatlong": "23.774929,-120.419416",
"X-Appengine-City": "city name",
"Via": "1.1 google",
"X-Forwarded-For": "1.2.3.4, 5.6.7.8"


问:
Why does HttpWebResponse try to decompress the stream using GZip when Content-Encoding is empty?
I've looked at a lot of Q&As around this subject and got to the point where I use the following code in order to get the bytes from a given URI:

```<code>var request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
var response = request.GetResponse();
var stream = response.GetResponseStream();
if (stream != null)
{
    var buffer = new byte[4097];
    var memoryStream = new MemoryStream();

    do
    {
        var count = stream.Read(buffer, 0, buffer.Length);
        memoryStream.Write(buffer, 0, count);

        if (count == 0)
            break;
    } while (true);

    return memoryStream.ToArray();
}

response.Close();

return null;
</code>```

Now, for a certain URI (which is pointing to a file), when debugging, I see that the 'Content-Encoding' header of the web response equals to nothing (""), but when trying to read from the stream, it throws an exception:

System.IO.InvalidDataException: The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.

When debugging the same URI in dev tools I get this on the response headers:

Content-Encoding:gzip,deflate

So I really don't know what happens.

Any clues and ideas on how to avoid this exception and successfully read the file's bytes?

Thanks!

答:
The .NET framework blanks this header out as part of the auto-decompression.  I would assume this is because you are asking the framework to handle it automatically and that the response stream you get back is no longer compressed.

I had to just look this up myself by inspecting the source code HttpWebResponse at Microsoft

Body:
I've looked at a lot of Q&As around this subject and got to the point where I use the following code in order to get the bytes from a given URI:

var request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
var response = request.GetResponse();
var stream = response.GetResponseStream();
if (stream != null)
{
    var buffer = new byte[4097];
    var memoryStream = new MemoryStream();

    do
    {
        var count = stream.Read(buffer, 0, buffer.Length);
        memoryStream.Write(buffer, 0, count);

        if (count == 0)
            break;
    } while (true);

    return memoryStream.ToArray();
}

response.Close();

return null;

Now, for a certain URI (which is pointing to a file), when debugging, I see that the 'Content-Encoding' header of the web response equals to nothing (""), but when trying to read from the stream, it throws an exception:

System.IO.InvalidDataException: The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.

When debugging the same URI in dev tools I get this on the response headers:

Content-Encoding:gzip,deflate

So I really don't know what happens.

Any clues and ideas on how to avoid this exception and successfully read the file's bytes?

Thanks!


问:
java - Thread.sleep
In the code and output below, t2 doesn't start until t1 finishes. Shouldn't they work parallel? Is Thread.sleep() affect whole process?

```<code>public class Main {

    public static void main(String[] args) {

        T t1 = new T(), t2 = new T();

        t1.run();
        t2.run();
    }
}

class Test {

    private int x;

    void foo() {

        synchronized (this){
            System.out.println("Entered");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Exit");
        }
    }
}

class T extends Thread {

    static Test t = new Test();

    public void run() {

        System.out.println("Thread started");
        t.foo();
    }

}
</code>```

Output:

Thread started

Entered

Exit

Thread started

Entered

Exit

答:
If you want to run these as separate threads, you need to call the Thread.start() method.

Instead, you're calling the run() method directly. The two calls will execute in the same thread as the caller.

As an aside, usually you can just subclass Runnable rather than Thread. Then you can choose to pass your Runnable to the Thread(Runnable) constructor -- or to an ExecutorService.

Title: java - Thread.sleep

Body:
In the code and output below, t2 doesn't start until t1 finishes. Shouldn't they work parallel? Is Thread.sleep() affect whole process?

public class Main {

    public static void main(String[] args) {

        T t1 = new T(), t2 = new T();

        t1.run();
        t2.run();
    }
}

class Test {

    private int x;

    void foo() {

        synchronized (this){
            System.out.println("Entered");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Exit");
        }
    }
}

class T extends Thread {

    static Test t = new Test();

    public void run() {

        System.out.println("Thread started");
        t.foo();
    }

}

Output:

Thread started

Entered

Exit

Thread started

Entered

Exit


问:
How to store API data (array) into database with php
I am having error trying to store data into a database. I need help on how best to fix this my code, so that my array content can be stored in a my database. When I tried to echo the content, it worked not to store the data in my database is the problem.
Here is my code:

```<code>foreach ($data['players'] as $myp) {
//    echo $myp["name"]."<br>";
    $name = $myp['name'];
    $posi = $myp['position'];
    $nation = $myp['nationality'];
    $market = $myp['marketValue'];
}

//insert into mysql table
mysql_select_db($db, $conn); //database and connection

$date = date('Y-m-d H:m:s'); //date stamp formatting
//sql query that insert the user info into the database
$sql =  "INSERT INTO staffdb ( Name, Position, Nationality, Market, Created)
        VALUES($name, $posi, $nation, $market, $date)";
echo $name . "<br>";
//if the connection is sucessful, display regards message
if (mysql_query($sql, $conn)) {
    echo "Thank you <br/>";
} else {   //if the connection is not established
    die('Error: ' . mysql_error());
}
</code>```

Here is the error I was getting:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Costa, Centre Forward, Spain, 45,000,000 €, 2017-03-31 23:03:04)' at line 2

In the error it printed the right value which i would like to be instead stored in the database.

Kindly correct my SQL part so that I can get my foreach data into my database.

Thanks alot!

答:
you need quotes around your values, plus you might want to use mysqli (as far as i know mysql_query etc. is deprecated.
Also with your code only the last player is inserted.. don't know if that's what you want?

in your foreach you could do something like $q .= "('$name', '$posi', '$nation', '$market', '$date'),";

And then after the foreach loop removing the last comma $q = rtrim($q, ",");

And then the sql query:  $sql = "INSERT INTO staffdb ( Name, Position, Nationality, Market, Created)VALUES".$q;

EDIT: something like this:

```<code>$values = "";
$date = date('Y-m-d H:m:s');
foreach ($data['players'] as $myp) {
//    echo $myp["name"]."<br>";
    $name = $myp['name'];
    $posi = $myp['position'];
    $nation = $myp['nationality'];
    $market = $myp['marketValue'];

    $values .= "('$name', '$posi', '$nation', '$market', '$date'),";
}
//remove last comma
$values = substr($values, 0,-1);

//mysqli connection
$conn = mysqli_connect("host", "user", "password", "database");

//sql query that insert the user info into the database
$sql =  "INSERT INTO staffdb ( Name, Position, Nationality, Market, Created)
        VALUES".$values;
//if the connection is sucessful, display regards message
mysqli_query($conn, $sql) or die('Error: ' . mysqli_error($conn));
echo "Thank you <br/>";
</code>```

Body:
I am having error trying to store data into a database. I need help on how best to fix this my code, so that my array content can be stored in a my database. When I tried to echo the content, it worked not to store the data in my database is the problem.
Here is my code:

foreach ($data['players'] as $myp) {
//    echo $myp["name"]."
";
    $name = $myp['name'];
    $posi = $myp['position'];
    $nation = $myp['nationality'];
    $market = $myp['marketValue'];
}

//insert into mysql table
mysql_select_db($db, $conn); //database and connection

$date = date('Y-m-d H:m:s'); //date stamp formatting
//sql query that insert the user info into the database
$sql =  "INSERT INTO staffdb ( Name, Position, Nationality, Market, Created)
        VALUES($name, $posi, $nation, $market, $date)";
echo $name . "
";
//if the connection is sucessful, display regards message
if (mysql_query($sql, $conn)) {
    echo "Thank you
";
} else {   //if the connection is not established
    die('Error: ' . mysql_error());
}

Here is the error I was getting:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Costa, Centre Forward, Spain, 45,000,000 €, 2017-03-31 23:03:04)' at line 2

In the error it printed the right value which i would like to be instead stored in the database.

Kindly correct my SQL part so that I can get my foreach data into my database.

Thanks alot!

Body:
you need quotes around your values, plus you might want to use mysqli (as far as i know mysql_query etc. is deprecated.
Also with your code only the last player is inserted.. don't know if that's what you want?

in your foreach you could do something like $q .= "('$name', '$posi', '$nation', '$market', '$date'),";

And then after the foreach loop removing the last comma $q = rtrim($q, ",");

And then the sql query:  $sql = "INSERT INTO staffdb ( Name, Position, Nationality, Market, Created)VALUES".$q;

EDIT: something like this:

$values = "";
$date = date('Y-m-d H:m:s');
foreach ($data['players'] as $myp) {
//    echo $myp["name"]."<br>";
    $name = $myp['name'];
    $posi = $myp['position'];
    $nation = $myp['nationality'];
    $market = $myp['marketValue'];

    $values .= "('$name', '$posi', '$nation', '$market', '$date'),";
}
//remove last comma
$values = substr($values, 0,-1);

//mysqli connection
$conn = mysqli_connect("host", "user", "password", "database");

//sql query that insert the user info into the database
$sql =  "INSERT INTO staffdb ( Name, Position, Nationality, Market, Created)
        VALUES".$values;
//if the connection is sucessful, display regards message
mysqli_query($conn, $sql) or die('Error: ' . mysqli_error($conn));
echo "Thank you <br/>";


问:
vb.net RichTextBox Environment.NewLine not showing CR only LF
After I run the following in vb.net I am only showing a "LF" and no "CR" (notepad++)

When I copy and paste or open the saved file in notepad it only returns on one line.  Digging deeper I notice there are no CR and only LF.  Any advice on why the CR is not showing up?  The file looks great in RichTextBox.

```<code>        RichTextReport.AppendText("Printer Report:" + Environment.NewLine)
        RichTextReport.AppendText(sDate + " : " + sTime + Environment.NewLine)
        RichTextReport.AppendText("something")
        RichTextReport.AppendText(Environment.NewLine)
</code>```

答:
These are the character sequences to create a new line:

vbCr is the carriage return (return to line beginning),

vbLf is the line feed (go to next line),

vbCrLf is the carriage return / line feed (similar to pressing Enter)

You can also call vbNewLine as well.

Body:
After I run the following in vb.net I am only showing a "LF" and no "CR" (notepad++)

When I copy and paste or open the saved file in notepad it only returns on one line.  Digging deeper I notice there are no CR and only LF.  Any advice on why the CR is not showing up?  The file looks great in RichTextBox.

        RichTextReport.AppendText("Printer Report:" + Environment.NewLine)
        RichTextReport.AppendText(sDate + " : " + sTime + Environment.NewLine)
        RichTextReport.AppendText("something")
        RichTextReport.AppendText(Environment.NewLine)


问:
Stochastic gradient descent implementation with Python's numpy
I have to implement stochastic gradient descent using python numpy library. For that purpose I'm given the following function definitions:

```<code>def compute_stoch_gradient(y, tx, w):
    """Compute a stochastic gradient for batch data."""

def stochastic_gradient_descent(
        y, tx, initial_w, batch_size, max_epochs, gamma):
    """Stochastic gradient descent algorithm."""
</code>```

I'm also given the following help function:

```<code>def batch_iter(y, tx, batch_size, num_batches=1, shuffle=True):
    """
    Generate a minibatch iterator for a dataset.
    Takes as input two iterables (here the output desired values 'y' and the input data 'tx')
    Outputs an iterator which gives mini-batches of `batch_size` matching elements from `y` and `tx`.
    Data can be randomly shuffled to avoid ordering in the original data messing with the randomness of the minibatches.
    Example of use :
    for minibatch_y, minibatch_tx in batch_iter(y, tx, 32):
        <DO-SOMETHING>
    """
    data_size = len(y)

    if shuffle:
        shuffle_indices = np.random.permutation(np.arange(data_size))
        shuffled_y = y[shuffle_indices]
        shuffled_tx = tx[shuffle_indices]
    else:
        shuffled_y = y
        shuffled_tx = tx
    for batch_num in range(num_batches):
        start_index = batch_num * batch_size
        end_index = min((batch_num + 1) * batch_size, data_size)
        if start_index != end_index:
            yield shuffled_y[start_index:end_index], shuffled_tx[start_index:end_index]
</code>```

I implemented the following two functions:

```<code>def compute_stoch_gradient(y, tx, w):
    """Compute a stochastic gradient for batch data."""
    e = y - tx.dot(w)
    return (-1/y.shape[0])*tx.transpose().dot(e)

def stochastic_gradient_descent(y, tx, initial_w, batch_size, max_epochs, gamma):
    """Stochastic gradient descent algorithm."""
    ws = [initial_w]
    losses = []
    w = initial_w
    for n_iter in range(max_epochs):
        for minibatch_y,minibatch_x in batch_iter(y,tx,batch_size):
            w = ws[n_iter] - gamma * compute_stoch_gradient(minibatch_y,minibatch_x,ws[n_iter])
            ws.append(np.copy(w))
            loss = y - tx.dot(w)
            losses.append(loss)

    return losses, ws
</code>```

I'm not sure the iteration should be done in range(max_epochs) or in a larger range. I say this because I read that an epoch is "each time we run through the entire data set". So I think an epoch consists on more of one iteration...

答:
In a typical implementation, a mini-batch gradient descent with batch size B should pick B data points from the dataset randomly and update the weights based on the computed gradients on this subset. This process itself will continue many number of times until convergence or some threshold maximum iteration. Mini-batch with B=1 is SGD which can be noisy sometimes.

Along with the above comments, you may want to play with the batch size and the learning rate (step size) since they have significance impact on the convergence rate of stochastic and mini-batch gradient descent.

The following plots show the impacts of these two parameters on the convergence rate of SGD with logistic regression while doing sentiment analysis on amazon product review dataset, an assignment that appeared in a coursera course on Machine Learning - Classification by the University of Washington:

For more detailed information on this you may refer to https://sandipanweb.wordpress.com/2017/03/31/online-learning-sentiment-analysis-with-logistic-regression-via-stochastic-gradient-ascent/?frame-nonce=987e584e16

Body:
I have to implement stochastic gradient descent using python numpy library. For that purpose I'm given the following function definitions:

def compute_stoch_gradient(y, tx, w):
    """Compute a stochastic gradient for batch data."""

def stochastic_gradient_descent(
        y, tx, initial_w, batch_size, max_epochs, gamma):
    """Stochastic gradient descent algorithm."""

I'm also given the following help function:

def batch_iter(y, tx, batch_size, num_batches=1, shuffle=True):
    """
    Generate a minibatch iterator for a dataset.
    Takes as input two iterables (here the output desired values 'y' and the input data 'tx')
    Outputs an iterator which gives mini-batches of `batch_size` matching elements from `y` and `tx`.
    Data can be randomly shuffled to avoid ordering in the original data messing with the randomness of the minibatches.
    Example of use :
    for minibatch_y, minibatch_tx in batch_iter(y, tx, 32):
        <DO-SOMETHING>
    """
    data_size = len(y)

    if shuffle:
        shuffle_indices = np.random.permutation(np.arange(data_size))
        shuffled_y = y[shuffle_indices]
        shuffled_tx = tx[shuffle_indices]
    else:
        shuffled_y = y
        shuffled_tx = tx
    for batch_num in range(num_batches):
        start_index = batch_num * batch_size
        end_index = min((batch_num + 1) * batch_size, data_size)
        if start_index != end_index:
            yield shuffled_y[start_index:end_index], shuffled_tx[start_index:end_index]

I implemented the following two functions:

def compute_stoch_gradient(y, tx, w):
    """Compute a stochastic gradient for batch data."""
    e = y - tx.dot(w)
    return (-1/y.shape[0])*tx.transpose().dot(e)

def stochastic_gradient_descent(y, tx, initial_w, batch_size, max_epochs, gamma):
    """Stochastic gradient descent algorithm."""
    ws = [initial_w]
    losses = []
    w = initial_w
    for n_iter in range(max_epochs):
        for minibatch_y,minibatch_x in batch_iter(y,tx,batch_size):
            w = ws[n_iter] - gamma * compute_stoch_gradient(minibatch_y,minibatch_x,ws[n_iter])
            ws.append(np.copy(w))
            loss = y - tx.dot(w)
            losses.append(loss)

    return losses, ws

I'm not sure the iteration should be done in range(max_epochs) or in a larger range. I say this because I read that an epoch is "each time we run through the entire data set". So I think an epoch consists on more of one iteration...


问:
Custom workflow activity errors 'Value cannot be null'
I'm creating a custom workflow activity in VS2010 targeting .NET 3.5. The DLL is actually being used in a Microsoft System Center Service Manager custom workflow, but I don't think that is my issue.

I have a public string property, that the user types in the string of what the activity should use. However, when the WF runs, it errors out 'value cannot be null'. I want to target if it is my code or something else.

When we drag my custom activity onto the designer, I'm able to type in the text of the string on the designer for that property.

```<code>public static DependencyProperty ChangeRequestStageProperty = DependencyProperty.Register("ChangeRequestStage", typeof(String), typeof(UpdateChangeRequestStage));

    [DescriptionAttribute("The value to set the ChangeRequestStage Property in the ChangeRequest Extension class.")]
    [CategoryAttribute("Change Request Extension")]
    [BrowsableAttribute(true)]
    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    public String Stage
    {
        get { return ((String)(base.GetValue(UpdateChangeRequestStage.ChangeRequestStageProperty))); }
        set { base.SetValue(UpdateChangeRequestStage.ChangeRequestStageProperty, value); }
    }

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
    {
        EnterpriseManagementGroup emg = CreateEMG();

        //System.WorkItem.ChangeRequest Extension - ClassExtension_928bec0a_cac4_4a0a_bd89_7146c9052fbe
        ManagementPackClass mpcChangeRequest = emg.EntityTypes.GetClass(new Guid("8c6c6057-56ad-3862-47ec-dc0dde80a071"));

        //System.WorkItemContainsActivity Relationship Class
        ManagementPackRelationship workItemContainsActivityRelationship = emg.EntityTypes.GetRelationshipClass(new Guid("2DA498BE-0485-B2B2-D520-6EBD1698E61B"));

        EnterpriseManagementObject changeRequest = null;

        //Loop thru each emo (Change Request in this case), and assign it. There will never be more than 1 emo returned
        foreach (EnterpriseManagementObject obj in emg.EntityObjects.GetRelatedObjects<EnterpriseManagementObject>(executionContext.ContextGuid, workItemContainsActivityRelationship, TraversalDepth.OneLevel, ObjectQueryOptions.Default))
        { changeRequest = obj; }

        EnterpriseManagementObjectProjection emop = new EnterpriseManagementObjectProjection(changeRequest);

        if (emop != null)
        { emop.Object[mpcChangeRequest, "ChangeRequestStage"].Value = Stage; }

        emop.Commit();

        return base.Execute(executionContext);
    }
</code>```

Since it is getting a 'value cannot be null' error, I'm guessing it's on this line:

```<code>emop.Object[mpcChangeRequest, "ChangeRequestStage"].Value = Stage;
</code>```

I'm going to test and see if hardcoding a value works or not. Any ideas?
    enter code here

答:
try this</p>

```<code>if (emop != null && emop.Object[mpcChangeRequest, "ChangeRequestStage"] != null)
   emop.Object[mpcChangeRequest, "ChangeRequestStage"].Value = Stage
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I'm creating a custom workflow activity in VS2010 targeting .NET 3.5. The DLL is actually being used in a Microsoft System Center Service Manager custom workflow, but I don't think that is my issue.

I have a public string property, that the user types in the string of what the activity should use. However, when the WF runs, it errors out 'value cannot be null'. I want to target if it is my code or something else.

When we drag my custom activity onto the designer, I'm able to type in the text of the string on the designer for that property.

public static DependencyProperty ChangeRequestStageProperty = DependencyProperty.Register("ChangeRequestStage", typeof(String), typeof(UpdateChangeRequestStage));

    [DescriptionAttribute("The value to set the ChangeRequestStage Property in the ChangeRequest Extension class.")]
    [CategoryAttribute("Change Request Extension")]
    [BrowsableAttribute(true)]
    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    public String Stage
    {
        get { return ((String)(base.GetValue(UpdateChangeRequestStage.ChangeRequestStageProperty))); }
        set { base.SetValue(UpdateChangeRequestStage.ChangeRequestStageProperty, value); }
    }

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
    {
        EnterpriseManagementGroup emg = CreateEMG();

        //System.WorkItem.ChangeRequest Extension - ClassExtension_928bec0a_cac4_4a0a_bd89_7146c9052fbe
        ManagementPackClass mpcChangeRequest = emg.EntityTypes.GetClass(new Guid("8c6c6057-56ad-3862-47ec-dc0dde80a071"));

        //System.WorkItemContainsActivity Relationship Class
        ManagementPackRelationship workItemContainsActivityRelationship = emg.EntityTypes.GetRelationshipClass(new Guid("2DA498BE-0485-B2B2-D520-6EBD1698E61B"));

        EnterpriseManagementObject changeRequest = null;

        //Loop thru each emo (Change Request in this case), and assign it. There will never be more than 1 emo returned
        foreach (EnterpriseManagementObject obj in emg.EntityObjects.GetRelatedObjects<EnterpriseManagementObject>(executionContext.ContextGuid, workItemContainsActivityRelationship, TraversalDepth.OneLevel, ObjectQueryOptions.Default))
        { changeRequest = obj; }

        EnterpriseManagementObjectProjection emop = new EnterpriseManagementObjectProjection(changeRequest);

        if (emop != null)
        { emop.Object[mpcChangeRequest, "ChangeRequestStage"].Value = Stage; }

        emop.Commit();

        return base.Execute(executionContext);
    }

Since it is getting a 'value cannot be null' error, I'm guessing it's on this line:

emop.Object[mpcChangeRequest, "ChangeRequestStage"].Value = Stage;

I'm going to test and see if hardcoding a value works or not. Any ideas?
    enter code here

Body:
try this

if (emop != null && emop.Object[mpcChangeRequest, "ChangeRequestStage"] != null)
   emop.Object[mpcChangeRequest, "ChangeRequestStage"].Value = Stage


问:
Ambiguous Mysql Column
I have this query

```<code>SELECT t.employee_id, t.timeinhour,t.timeouthour,
SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(t.timeouthour, t.timeinhour))))
AS Duration FROM timesheets t
INNER JOIN employeetimesheets et
ON t.employee_id=et.employee_id
WHERE employee_id='6748372'
AND timeinyear='2017'
AND timeinmonth='March'
AND isWeekNumber='1'
</code>```

It gives me this error

1052 - Column 'employee_id' in where clause is ambiguous

I have looked here and here but I'm not using all (*) so I don't understand why?

答:
The product of the tables from which you're selecting includes two columns of the same name, as evident here:

```<code>ON t.employee_id=et.employee_id
</code>```

Both timesheets and employeetimesheets have that column.  Since the JOIN clause will ensure that those two columns in the product will always have the same value, it might not really matter which you specify.  Either one will do the job:

```<code>WHERE t.employee_id='6748372'
</code>```

Though you may want to run a DESCRIBE on both and see if there's any difference in the performance.

Title: Ambiguous Mysql Column

Body:
I have this query

SELECT t.employee_id, t.timeinhour,t.timeouthour,
SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(t.timeouthour, t.timeinhour))))
AS Duration FROM timesheets t
INNER JOIN employeetimesheets et
ON t.employee_id=et.employee_id
WHERE employee_id='6748372'
AND timeinyear='2017'
AND timeinmonth='March'
AND isWeekNumber='1'

It gives me this error

1052 - Column 'employee_id' in where clause is ambiguous

I have looked here and here but I'm not using all (*) so I don't understand why?

Body:
The product of the tables from which you're selecting includes two columns of the same name, as evident here:

ON t.employee_id=et.employee_id

Both timesheets and employeetimesheets have that column.  Since the JOIN clause will ensure that those two columns in the product will always have the same value, it might not really matter which you specify.  Either one will do the job:

WHERE t.employee_id='6748372'

Though you may want to run a DESCRIBE on both and see if there's any difference in the performance.