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

Question - Set default / fixed value for an attribute #100

Open
silahide opened this issue Nov 14, 2019 · 4 comments
Open

Question - Set default / fixed value for an attribute #100

silahide opened this issue Nov 14, 2019 · 4 comments

Comments

@silahide
Copy link

Hi,

Is it possible to set a default or fixed value for an attribute? I can set it in the xsd but then I cannot see it initialised in the PHP class.

Many thanks.

@silahide
Copy link
Author

silahide commented Nov 25, 2019

Hi,

Is there a way of initialising by default and attribute or a const in the php class through the schema? It would be useful to define something like:

<xs:attribute name="marvin" fixed="i.smp.pat.sampl"></xs:attribute> or
<xs:elemnt name="marvin" default="i.smp.pat.sampl"></xs:element>

And produce:
const MARVIN = "i.smp.pat.sample"; or
$marvin = "i.smp.pat.sample";

@goetas
Copy link
Member

goetas commented Nov 25, 2019

Hi, currently is not yet implemented, but should be not too hard to add it.

A good starting point is

private function visitAttribute(PHPClass $class, Schema $schema, AttributeItem $attribute, $arrayize = true)

Pull requests are welcome

@silahide
Copy link
Author

silahide commented Nov 27, 2019

Hi, I wouldn't mind to do it however I can only work as a user of this library.

If is not too hard to add it, could you label it as "feature request" or implement it?

It would be really handful for integrating data coming from different sources. For instance, if raw data is stored in a different XML, this feature streamlines the self-filling of values by writing only few lines of code. Thus makes sense to describe the id of the source of the data in the schema.

@goetas
Copy link
Member

goetas commented Nov 29, 2019

marked as feature request. feel free to submit an implementation for this feature.

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

No branches or pull requests

2 participants