Reputation: 1284
I want to convert my google protocol object to XML format. In that I would like to keep some fields as attribute. Instead of :
<field>
<name>ApiFieldHeaderName</name>
<maxLength>50</maxLength>
</field>
I want following :
<field name="ApiFieldHeaderName" maxLength="50" ></field>
My protocol is
string name = 1;
int32 maxLength = 2;
And then I have gone through some forum and used xml_disposition
[(xml_disposition) = ATTRIBUTE]
However, I am getting the error:
Option "(xml_disposition)" unknown.
I am using proto3 and language is Java.
syntax = "proto3";
option optimize_for = SPEED;
Upvotes: 1
Views: 1990
Reputation: 1063864
I believe you've found xml_disposition
from a side discussion on the protobuf newsgroup from 2009. The option mentioned, however, was purely hypothetical. As far as I know: no such xml_disposition
custom option exists - and least, not as a standard option - and no code-generator looks for it. No mention of xml_disposition
exists in the Google protobuf source, and the current version of protoc
(3.5.1) does not recognise it and an inbuilt option.
So:
Side note: custom options must be defined in "proto2" syntax files, but a "proto3" file can still import and use those custom options from the "proto2" file.
Upvotes: 1