Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute with NMTOKENS restriction generates array #113

Open
bcremer opened this issue May 26, 2020 · 2 comments
Open

Attribute with NMTOKENS restriction generates array #113

bcremer opened this issue May 26, 2020 · 2 comments
Labels

Comments

@bcremer
Copy link

bcremer commented May 26, 2020

This is a regression in #96.

Given the following XSD:

<xs:schema targetNamespace="http://www.example.com"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:complexType name="ExampleType">
            <xs:attribute name="ExampleAttribute">
                <xs:simpleType>
                    <xs:restriction base="xs:NMTOKENS">
                        <xs:enumeration value="Master"/>
                        <xs:enumeration value="Arrival"/>
                        <xs:enumeration value="Departure"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
</xs:schema>

Die restriction on the ExampleAttribute of type NMTOKENS is treated as an list/array.
The following PHP Code get generated:

    /**
     * Gets as exampleAttribute
     *
     * @return string[]
     */
    public function getExampleAttribute()
    {
        return $this->exampleAttribute;
    }

    /**
     * Sets a new exampleAttribute
     *
     * @param string $exampleAttribute
     * @return self
     */
    public function setExampleAttribute(array $exampleAttribute)
    {
        $this->exampleAttribute = $exampleAttribute;
        return $this;
    }

When using the almost exact xsd with xs:restriction base="xs:string" the attribute is treated a scalar:

<xs:schema targetNamespace="http://www.example.com"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:complexType name="ExampleType">
            <xs:attribute name="ExampleAttribute">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="Master"/>
                        <xs:enumeration value="Arrival"/>
                        <xs:enumeration value="Departure"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
</xs:schema>
    /**
     * Gets as exampleAttribute
     *
     * @return string
     */
    public function getExampleAttribute()
    {
        return $this->exampleAttribute;
    }

    /**
     * Sets a new exampleAttribute
     *
     * @param string $exampleAttribute
     * @return self
     */
    public function setExampleAttribute($exampleAttribute)
    {
        $this->exampleAttribute = $exampleAttribute;
        return $this;
    }
@goetas goetas added the bug label May 27, 2020
@goetas
Copy link
Member

goetas commented May 27, 2020

Hmm, right! that should be fixed!

@goetas
Copy link
Member

goetas commented Jan 24, 2021

@bcremer are you interested in providing a fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants