Part of the advice on policies for trans pupils may be unlawful, the attorney general advises.