users@jaxb.java.net

Re: namespaces by marshaller output

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 30 Sep 2008 17:11:28 +0200

What is the XML schema definition for the element tagged <TextOutlTxt>?

If you want to have HTML tags in the content text of that element then
it should have the type xsd:string.
The XML instance document would have to be written using &lt; and &gt;
instead of < and > or like this:
<TextOutlTxt><![CDATA[
<p>A paragraph.</p>
]]></TextOutlTxt>

The JAXB marshallier takes care of that.

-W


On Tue, Sep 30, 2008 at 4:31 PM, Boris Koprinarov
<bkoprinarov_at_googlemail.com> wrote:
>
> Hi All,
>
> I have some questions about jaxb Marshall output.
>
> My xml file:
>
> <GAEB>
> <GAEBInfo></GAEBInfo>
> <PrjInfo></PrjInfo>
> <Award>
> <DP>55</DP>
> <AwardInfo></AwardInfo>
> <OWN></OWN>
> <BoQ ID="123">
> <BoQInfo></BoQInfo>
> <BoQBody>
> <Remark ID="1">
> <Description>
> <CompleteText>
> <DetailTxt></DetailTxt>
> <OutlineText>
> <OutlTxt>
> <TextOutlTxt>
> <p>
> <"span">Erklaerung Einheitspreis/Gesamtbetrag<"/span"> (without "")
> </p>
> </TextOutlTxt>
> </OutlTxt>
> </OutlineText>
> </CompleteText>
> </Description>
> </Remark>
> </BoQBody>
> </BoQ>
> </Award>
> </GAEB>
>
>
> And here is my output from the marshaller:
> < xmlns:ns2="http://www.w3.org/2000/09/xmldsig#"
> xmlns:ns3="http://www.mytest.com">
> <ns3:TextOutlTxt>
> <ns3:p>
> <ns3:span>Erklärung Einheitspreis/Gesamtbetrag</ns3:span>
> </ns3:p>
> </ns3:TextOutlTxt>
> </>
>
> Between <TextOutlTxt> tags is some html code. I am trying to get that code
> as a "plain" html code without the xml tags. In my output there are
> 1. < xmlns:ns2="http://www.w3.org/2000/09/xmldsig#"
> xmlns:ns3="http://www.mytest.com">
>
> 2. <ns3:> namespace Prefix.
>
> Is there any way to remove them from my marshaller output?
>
> Here is my code:
>
> ---Unmarshaller :
>
> try {
> JAXBContext jaxbContext =
> JAXBContext.newInstance("my.package");
>
>
> iJaxbContext=jaxbContext;
>
> } catch (JAXBException ex) {
> LOGGER.info("Can not bind the xml file with the schema!"
> +
>
> ex.toString());
> }
>
> try {
> Unmarshaller unmarshaller =
> iJaxbContext.createUnmarshaller();
>
> JAXBElement<TgGAEB> GAEBtempElement = (JAXBElement<TgGAEB>)
> unmarshaller.unmarshal(this.getFile());
>
> iObject.addLookup(GAEBtempElement.getValue());
>
>
> } catch (JAXBException ex) {
> LOGGER.info("Can not get the Unmarshall for the xml file!"
> +
> ex.toString());
> }
>
>
>
> ---Marshaller:
>
> public String jaxbElementToString(Object aElement){
>
>
> StringWriter htmlString = new StringWriter();
> try {
>
>
> JAXBContext jaxbContext = JAXBContext.newInstance("my.package");
>
> iJaxbContext=jaxbContext;
>
> } catch (JAXBException ex) {
> LOGGER.info("Can not bind the xml file with the schema!"
> +
>
> ex.toString());
> }
>
> try {
>
> Marshaller marshaller = iJaxbContext.createMarshaller();
>
> marshaller.setProperty(marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE);
> marshaller.setProperty(marshaller.JAXB_FRAGMENT,Boolean.TRUE);
>
>
> JAXBElement el = new
> JAXBElement(myname,aElement.getClass(),aElement);
>
> java.io.StringWriter sw = new java.io.StringWriter();
> marshaller.marshal(el, sw);
>
> } catch (JAXBException ex) {
> LOGGER.info("Can not get the Unmarshall for the xml file!"
> +
> ex.toString());
> }
>
> return htmlString.toString();
> }
>
>
> Boris
> --
> View this message in context: http://www.nabble.com/namespaces-by-marshaller-output-tp19743303p19743303.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>