Page 1 of 1

org.docx4j.wml.SdtPr$Alias : @XmlRootElement annotation

PostPosted: Tue Apr 05, 2011 8:37 am
by smer4
Bug?
With
Code: Select all
...
SdtPr   sp1...
...
Alias a1 = factory.createSdtPrAlias();
a1.setVal("Alias");
sp1.getRPrOrAliasOrLock().add(a1);
....


i get
Code: Select all
[com.sun.istack.internal.SAXException2: unable to marshal type "org.docx4j.wml.SdtPr$Alias" as an element because it is missing an @XmlRootElement annotation]


And true, cause the @XmlRootElement annotationis given to the SdtPr itself.
But how else can i set the Alias ?

did you forget to make a SdtPr.setAlias() method like with setTag or someth?

Re: org.docx4j.wml.SdtPr$Alias : @XmlRootElement annotation

PostPosted: Tue Apr 05, 2011 9:42 am
by jason
r1465 adds the @XmlRootElement to alias.

Re: org.docx4j.wml.SdtPr$Alias : @XmlRootElement annotation

PostPosted: Sat Nov 22, 2014 12:26 am
by carraway
I know this is a Thead of the past, but I searched for a solution for this. I'm using Docx4J 3.2.1

How to set an Alias to a SdtPr:

Code: Select all
ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();

SdtPr sdtPr = wmlObjectFactory.createSdtPr();
      
List<Object> sdtPrParts = sdtPr.getRPrOrAliasOrLock();
Alias alias = wmlObjectFactory.createSdtPrAlias();
alias.setVal("Title");
sdtPrParts.add(alias);

Re: org.docx4j.wml.SdtPr$Alias : @XmlRootElement annotation

PostPosted: Sat Nov 22, 2014 8:05 am
by jason
So what happens when you do that?

ie what is the output of XmlUtils.unmarshallToString(yourSdt)?