The best idea (aka poor man's solution)
will be to have two main files (say first.tex and second.tex) which will have content unique to them. The shared content may be in a third file (say shared.tex) which can be \inputed inside first.tex and second.tex. Hence you will have totally three files.
If you want all the three files inside a single file and want to compile (click the pdflatex button ,-)) only once, you may use the filecontents and \write facility:
(name this file as first.tex)
\documentclass{article} %% The output of this file is the first document.
\usepackage{filecontents}%
%%
%% The shared content
\begin{filecontents*}{shared.tex}
This content is shared by both the files -- \verb|first.tex| and \verb|second.tex|
\end{filecontents*}
%%
%% This is the second document
\begin{filecontents*}{second.tex}
\documentclass{article}
\begin{document}
This is the unique content for the second file. Next comes the shared content.
\section{shared content}
\input{shared}
Again some unique content for second file.
\end{document}
\end{filecontents*}
%%
%create the second.pdf.
\immediate\write18{pdflatex second}
\begin{document}
This will appear only in the first file. I am going crazy!
\section{shared content}
\input{shared}
Again this is only for first file.
\end{document}
You will get two pdf files - first.pdf and second.pdf. The contents of first.pdf are

and the second.pdf reads:

pgfkeyspackage is excellent for parsing key-value pairs and thepgfoptspackage lets you usepgfkeysat the document class level. As to the style, thst's up to yourself. For example, you could load classXif optionAis passed, load classYif optionBis passed, and so on. – Dec 26 '12 at 08:15pdfpagespackage – smh Dec 26 '12 at 10:49documentclassper document. However, you can generate two pdfs from the shell level.echo '\ifcsname ifarticle\endcsname\else\expandafter\let\csname ifarticle\expandafter\endcsname\csname iffalse\endcsname\fi\ifarticle\documentclass{article}\else\documentclass{book}\fi\title{Example}\author{Somebody}\begin{document}\maketitle\end{document}' > ex.tex; pdflatex "\let\ifarticle\iffalse\input{ex}"; mv ex.pdf book.pdf; pdflatex "\let\ifarticle\iftrue\input{ex}"; mv ex.pdf article.pdf– Dec 26 '12 at 10:56