
84 Wis.2d 224 (1978)
267 N.W.2d 25
BENCE, and others, Plaintiffs-Respondents,
v.
CITY OF MILWAUKEE, and another, Defendants-Appellants.
No. 76-027.
Supreme Court of Wisconsin.
Submitted on briefs May 3, 1978.
Decided June 30, 1978.
*226 For the appellants the cause was submitted on the brief of James B. Brennan, city attorney, Richard F. Maruszewski, and William J. Lukacevich, assistant city attorneys.
For the respondents the cause was submitted on the brief of Ewald L. Moerke, Jr., and Schroeder, Gedlen, Riester & Moerke of Milwaukee.
HEFFERNAN, J.
The appeal is from an order overruling a demurrer to the plaintiffs' complaint for declaratory judgment.
The plaintiffs, who are a class of retired police officers and employees of the Milwaukee Police Department, alleged that Charter Ordinance 410, adopted by the Milwaukee Common Council in 1974, was unconstitutional, because it deprived the plaintiffs of their constitutional rights of equal protection and due process in respect to their pensions. They sought a declaration of unconstitutionality pursuant to sec. 269.56, Stats. (now renumbered as sec. 806.04(2)).[1]
The Policemen's Annuity and Benefit Fund, which was established by the City of Milwaukee, administers two *227 basic pension systems, one for officers who entered service prior to May 17, 1945, and the other for officers who entered the service between May 17, 1945, and July 29, 1947. Police officers who entered the department after the latter date are under a separately administered employees retirement system of the City of Milwaukee.
The officers of whom the named plaintiffs are representative entered the service between May 17, 1945, and July 29, 1947, and retired prior to October 5, 1973. Their pensions were based on the average of their last three years' salary. Those officers whose service commenced between May 17, 1945, and July 29, 1947, but who retired subsequent to October 5, 1973, are paid pensions based on their highest one year's salary.
It is the argument of the class which brought this lawsuit that the operation of the ordinance which excludes them from a higher pension basis is the result of a violation of due process and denies them equal protection.
The plaintiffs petitioned the common council for redress; and upon being unsuccessful with the council, they brought an action for declaratory judgment for the purpose of having the court declare unconstitutional the portions of the ordinance which exclude the plaintiffs from the class entitled to increased benefits.
A resume of the chronology is appropriate for an understanding of the present posture of the case.
Originally, the police officers whose service commenced between May 17, 1945, and July 29, 1947, were entitled to receive pensions amounting to 50 percent of the average of their last five years' salary upon retirement after twenty-five years of service. Collective bargaining agreements subsequently changed the method for determining pensions. A 1971 agreement changed the basis from 50 percent of the average of the last five years' salary for employees entering service between May 17, 1945, and *228 July 29, 1947, and who were active on or after January 1, 1971, to 50 percent of the average salary of the last three years.
A collective bargaining agreement entered into on October 15, 1973, precipitated this lawsuit. That 1973 agreement provided that all officers who entered service on or after May 17, 1945, and who were still on active duty would have their pensions computed on the basis of 50 percent of the highest salary earned in any one year.
Charter Ordinance 410 was adopted to implement that collective bargaining agreement. The charter ordinance provided that officers within the class, and on active duty on October 5, 1973, would be entitled to pensions based on the revised method of computation. The effect of the charter ordinance, it is alleged, is to afford lower pension rights (in comparison to the new class created by the ordinance) to the 36 officers who retired prior to October 5, 1973, but to permit an increase in retirement benefits for other officers who entered the service at or about the same time but remained on active duty on October 5, 1973. This, it is claimed, results in an arbitrary and unreasonable classification which denies the plaintiffs equal protection.
It is also claimed that the plaintiffs were denied due process because they were not represented in the collective bargaining negotiations that led up to the 1973 agreement and the 1974 ordinance.
The City of Milwaukee and the Policemen's Annuity and Benefit Fund demurred to the complaint on three grounds: That the complaint did not state a cause of action, that there was a defect of parties, in that not all persons having an interest in the pension fund who would be affected by the declaration had been made parties, and that the court lacked subject matter jurisdiction for failure to serve the attorney general as required by sec. 806.04(11), Stats. The latter defect was cured by service on *229 the attorney general, and the trial court considered the demurrer only on the first two grounds.
We address ourselves first to the question of whether the complaint states a cause of action for declaratory judgment. We conclude that it does and that the demurrer of the defendants on that basis was properly overruled by the trial court. We have said that, in order to state a cause of action under the declaratory judgment statute, a complaint must set forth:
"(1) A justiciable controversy (2) ripe for judicial determination (3) between persons whose interests are adverse and (4) involving a legally protectible interest in the plaintiff." American Medical Services, Inc. v. Mutual Federal Savings & Loan Assn, 52 Wis.2d 198, 203, 188 N.W.2d 529 (1971).
The defendants do not dispute that the first three requirements have been satisfied. They base their demurrer in respect to whether a cause of action is stated on the assertion that the plaintiffs have no legally protectible interest in the controversy. They contend that the plaintiffs are receiving the benefits promised to them when they retired and their rights are unaffected by the collective bargaining agreement of 1973 and the ordinance that followed.
[1]
While there may be some validity to the defendants' position, their argument goes to the ultimate meritsthe question of whether the plaintiffs in fact have a legally protectible interest at stake in the controversyrather than to the question, appropriate at this stage of the declaratory judgment action, of whether the plaintiffs have pleaded the existence of such an interest. The question on demurrer is not whether a plaintiff has an interest which is to be protected but whether it has pleaded that such an interest exists.
*230 The defendants' position may well be appropriate when the trial court addresses itself to the merits of the case, but it is inappropriate at this juncture. We previously stated the rule in respect to a demurrer to a complaint for declaratory judgment in Waukesha Memorial Hospital, Inc. v. Baird, 45 Wis.2d 629, 633, 173 N.W.2d 700 (1970):
"When there is a demurrer to a complaint for a declaratory judgment, the question presented initially is not whether the complaint so states a meritorious cause of action that the plaintiffs should prevail on the merits if, in fact, the facts alleged are true, but rather it poses the question of whether the controversy is one which should be considered and heard on the merits. An order overruling the demurrer and holding that a proper cause of action for declaratory judgment exists permits the exploration of the merits. The question raised on appeal is simply whether the declaratory judgment device may be properly used to adjudicate the plaintiffs' claim."
The same rule, with the reasons for it, is expressed in 1 W. Anderson, Actions for Declaratory Judgments, sec. 318 (1951):
"When an action is filed for a declaratory judgment and the plaintiffs set forth facts of an actual controversy concerning some matter covered by the declaratory judgment statute, it may be stated generally that it is the duty of the trial court to overrule a demurrer to the plaintiff's pleading and proceed with the case in accordance with the provisions of the statute.
"The soundness of this general rule is obvious; while there may be cases in which no facts a plaintiff might plead, and no contentions he might make could possibly warrant the granting of the relief, but generally it may be conceded that it was not the intention of the declaratory judgment act to prejudge matters which might become pertinent in determining the propriety or justice of the relief sought. This would seem to be doubly true where the constitutionality of a statute or ordinance affecting public interest is involved." (footnote omitted) (at 740)
*231 "The test of the sufficiency of a complaint in a declaratory judgment proceeding is not whether the complaint shows that the plaintiff is entitled to the declaration of rights in accordance with his theory, but whether he is entitled to a declaration of rights at all, so that even if the plaintiff is on the wrong side of the controversy, if he states the existence of a controversy which should be settled, he states a cause of suit for a declaratory judgment. And where a complaint in a proceeding for a declaratory judgment stated a justiciable controversy, a demurrer should have been overruled, and after the filing of an answer, a decree containing a declaration of right should have been entered." (footnote omitted) (at 744)
[2, 3]
By demurring to the complaint, the defendants acknowledged the truth of the facts asserted therein; and, accordingly, the only question posed on demurrer is whether the facts are sufficient to entitle the plaintiffs to a declaration of rights. As the above authorities make clear, for the facts to constitute a cause of action for declaratory judgment, it is not necessary that the plaintiff show by those facts that it is entitled to prevail and to secure the relief asked for. The question is whether the plaintiff is entitled to a declaration of rights at all and if, as Anderson says, "he states the existence of a controversy which should be settled, he states a cause of suit for a declaratory judgment," even though he is on the wrong side of the controversy and the declaration he seeks is not one that will be granted after trial on the merits. Applying this standard, we conclude that a cause of action for declaratory judgment has been stated.
The plaintiffs in their complaint set forth the different classifications which the pension plan has adopted in respect to retired police officers who have entered the service at or about the same time but whose retirement dates occurred subsequent to October 5, 1973. Plaintiffs allege that they were not represented in the collective *232 bargaining procedures, that the classifications adopted by the ordinance were arbitrary and unreasonable in that the persons falling into the two classes are similarly situated and, in law should have been given the same benefits, and that such unequal treatment denied them of property without due process of law and denied them equal protection because of an unlawful and discriminatory classification.
[4]
We conclude that the portions of the complaint referred to sufficiently assert a justiciable controversy which is ripe for determination between the plaintiffs, on the one hand, and the city and the pension fund, on the other. Such controversy, under the facts alleged, involves an interest in the plaintiffs which may be legally protectible under their theory of the law. Whether that theory is correct, and in fact is sufficient to convince the trial court of the ultimate merits of the plaintiffs' case, is not now before the court.
The complaint sufficiently states a cause of action for declaratory judgment, and we affirm the determination of the trial court in this respect.
An additional basis for demurrer was urged by the defendants and again on this appeal. The plaintiffs' complaint did not join other police officers who were receiving pensions under the ordinance. The defendants contend that this failure constituted a defect of parties defendant and that the demurrer should be sustained for the failure to join necessary parties. The declaratory judgment provisions of the statute do indeed provide that a declaratory judgment shall not prejudice rights of persons who are not made parties to the proceeding. Sec. 806.04(11), Stats., states:
"(11) Parties. When declaratory relief is sought, all persons shall be made parties who have or claim any interest which would be affected by the declaration, and *233 no declaration shall prejudice the right of persons not parties to the proceeding. In any proceeding which involves the validity of a municipal ordinance or franchise, such municipality shall be made a party, and shall be entitled to be heard, and if the statute, ordinance or franchise is alleged to be unconstitutional, the attorney general shall also be served with a copy of the proceeding and be entitled to be heard."
The question basically, however, is whether the parties who have not been joinedother policemen who have retired and are receiving pensionsnecessarily would be affected by the declaration. The theory of the defendants is that granting the relief that the plaintiffs seek would require the total invalidation of the ordinance and that this would necessarily affect the interest of other police officers.
We believe, however, that the trial court correctly overruled the demurrer on that asserted ground, because the ordinance is severable. The trial judge reasoned that, in the event it was found at trial that the classification made by the ordinance was impermissible, he could find the ordinance unconstitutional in respect to the plaintiffs without affecting the interests of other police officers who are receiving increased benefits under the ordinance. He concluded that it was therefore unnecessary to join the other officers. We conclude that he properly perceived the problem as being one of severability. He stated that, were the classification in respect to the plaintiff officers to be found unconstitutional, it would be possible to remove from the ordinance the words which restricted the plaintiffs from being covered by the increased benefits without invalidating or affecting the rights of the other officers.
[5]
There is ample precedent to permit a court to sever from an ordinance or legislative enactment that portion *234 of an act which is unconstitutional and to declare that the remaining portion is valid. As a general matter, the determination of whether an invalid portion so infects the remainder of the legislation as to require the entire law to be invalidated is a question of legislative intent. City of Madison v. Nickel, 66 Wis.2d 71, 223 N.W.2d 865 (1974); State ex rel. Milwaukee County v. Boos, 8 Wis. 2d 215, 99 N.W.2d 139 (1959). Were the trial court to find the ordinance unconstitutional, it would appear not unreasonable to hold that the offending portions of the ordinance could be severed from the balance without violating the legislative intent in respect to the remainder. The ultimate determination of legislative intent would, however, have to abide the trial court's determination of unconstitutionality.
[6]
There is, in addition, a more compelling reason for upholding the trial court's conclusion that it was not necessary to join all other officers whose interests might possibly be affected by holding all or a portion of the ordinance unconstitutional. That reason was explained in Barry Laboratories, Inc. v. State Board of Pharmacy, 26 Wis.2d 505, 512, 132 N.W.2d 833 (1965), and in White House Milk Co. v. Thomson, 275 Wis.2d 243, 81 N.W.2d 725 (1957). In those cases, this court refused in a declaratory judgment action to require the joinder of all persons whose interests might be affected, because it was recognized that this stricture of the statute, if given a literal interpretation, would make the statute unworkable with respect to the determination of the validity of a statute or ordinance.
The court in White House Milk pointed out that it was sufficient where a public law was involved to have the interest of other parties represented by the public officer who has the duty of upholding the constitutionality of the *235 statute. That duty encompasses the obligation to act in a representative capacity on behalf of all persons who have an interest in upholding the legislation. That is clearly the situation in the instant case. The city attorney has appeared on behalf of the City of Milwaukee and of the Policemen's Annuity and Benefit Fund. It is his duty, a duty which he has discharged to date in this action, to represent the interests of the fund and the interests of all participants in the fund whose rights might be jeopardized by the decision in the declaratory judgment action.
[8]
We conclude that, under the rationale of White House Milk and Barry Laboratories, the interests of other police officers in the fund are sufficiently represented, even though they are not joined as defendants. The statute, as interpreted by this court, does not require their joinder.
We conclude that the complaint of the plaintiffs states a cause of action under the declaratory judgment statute and that no necessary parties have been omitted.
By the Court.Order affirmed.
NOTES
[1]  "806.04 Declaratory Judgments.

". . . .
"(2) Power to Construe, etc. Any person interested under a deed, will, written contract or other writings constituting a contract, or whose rights, status or other legal relations are affected by a statute, municipal ordinance, contract or franchise, may have determined any question of construction or validity arising under the instrument, statute, ordinance, contract or franchise and obtain a declaration of rights, status or other legal relations thereunder. No party shall be denied the right to have declared the validity of any statute or municipal ordinance by virtue of the fact that the party holds a license or permit under such statutes or ordinances."
