Changeset 532


Ignore:
Timestamp:
08/22/08 03:02:48 (4 years ago)
Author:
jharrop
Message:

RelationshipsPart? is now a JAXB part.

Location:
trunk/docx4j/src/main/java/org/docx4j
Files:
5 added
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/convert/in/XmlPackage.java

    r511 r532  
    2323 
    2424 
     25import java.net.URI; 
    2526import java.net.URISyntaxException; 
    2627import java.util.HashMap; 
     
    4748import org.docx4j.openpackaging.parts.PartName; 
    4849import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart; 
    49 import org.docx4j.openpackaging.parts.relationships.Relationship; 
    5050import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    51 import org.docx4j.openpackaging.parts.relationships.TargetMode; 
     51import org.docx4j.relationships.Relationships; 
     52import org.docx4j.relationships.Relationship; 
    5253 
    5354 
     
    165166                        org.w3c.dom.Element el = part.getXmlData().getAny(); 
    166167                         
    167                         // Convert it to a Dom4J element 
    168                          
    169                         thePart = new RelationshipsPart( p, new PartName( partName), convertW3CtoDom4J(el) ); 
    170                                 // PartName already starts with a '/', so no need to add it 
     168                        RelationshipsPart rp = new RelationshipsPart(new PartName(partName) ); 
     169                        // PartName already starts with a '/', so no need to add it 
     170                        rp.setSourceP(p); 
     171                        rp.unmarshal(el); 
     172                         
     173//                      // Convert it to a Dom4J element 
     174//                      thePart = new RelationshipsPart( p, new PartName( partName), convertW3CtoDom4J(el) ); 
     175//                              // PartName already starts with a '/', so no need to add it 
    171176                         
    172177                } catch (Exception e) { 
     
    209214                Package pkg = source.getPackage();                               
    210215                 
    211                 for (Iterator it = rp.iterator(); it.hasNext(); ) { 
    212                         Relationship r = (Relationship)it.next(); 
    213                         log.info("For Relationship Id=" + r.getId() + " Source is "  
    214                                         + r.getSource().getPartName()  
    215                                         + ", Target is " + r.getTargetURI() ); 
    216                         try { 
    217                                  
     216//              for (Iterator it = rp.iterator(); it.hasNext(); ) { 
     217//                      Relationship r = (Relationship)it.next(); 
     218//                      log.info("For Relationship Id=" + r.getId() + " Source is "  
     219//                                      + r.getSource().getPartName()  
     220//                                      + ", Target is " + r.getTargetURI() ); 
     221//                      try { 
     222//                               
     223//                              getPart(pkg, rp, r); 
     224//                               
     225//                      } catch (Exception e) { 
     226//                              throw new Docx4JException("Failed to add parts from relationships", e); 
     227//                      } 
     228//              } 
     229                 
     230                for ( Relationship r : rp.getRelationships().getRelationship() ) { 
     231                         
     232                        log.info("For Relationship Id=" + r.getId()  
     233                                        + " Source is " + rp.getSourceP().getPartName()  
     234                                        + ", Target is " + r.getTarget() ); 
     235                        try {                            
    218236                                getPart(pkg, rp, r); 
    219                                  
    220237                        } catch (Exception e) { 
    221238                                throw new Docx4JException("Failed to add parts from relationships", e); 
    222239                        } 
    223240                } 
     241                 
    224242                 
    225243                 
     
    241259         */ 
    242260        private void getPart( Package pkg, RelationshipsPart rp, Relationship r) 
    243                         throws Docx4JException, InvalidFormatException { 
     261                        throws Docx4JException, InvalidFormatException, URISyntaxException { 
    244262                 
    245263                Base source = null; 
    246264                String resolvedPartUri = null; 
    247265                 
    248                 if (r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     266                if (r.getTargetMode() == null 
     267                                || !r.getTargetMode().equals("External") ) { 
    249268                         
    250269                        // Usual case 
    251270                         
    252                         source = r.getSource(); 
    253                         resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString();              
     271//                      source = r.getSource(); 
     272//                      resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString();              
     273                        source = rp.getSourceP(); 
     274                        resolvedPartUri = URIHelper.resolvePartUri(rp.getSourceURI(), new URI(r.getTarget() ) ).toString();              
    254275 
    255276                        // Don't drop leading "/' in Xml Package 
     
    265286                         */ 
    266287 
    267                         log.warn("Encountered external resource " + r.getTargetURI()  
    268                                            + " of type " + r.getRelationshipType() ); 
     288                        log.warn("Encountered external resource " + r.getTarget()  
     289                                           + " of type " + r.getType() ); 
    269290                         
    270291                        // As of 1 May 2008, we don't do anything with these yet. 
     
    279300                } 
    280301                 
    281                 String relationshipType = r.getRelationshipType();               
     302                String relationshipType = r.getType();           
    282303                         
    283304                Part part = getRawPart(ctm, resolvedPartUri); 
  • trunk/docx4j/src/main/java/org/docx4j/convert/out/xmlPackage/XmlPackage.java

    r511 r532  
    2222 
    2323import java.io.IOException; 
     24import java.net.URI; 
    2425import java.util.Iterator; 
    2526 
     
    3435import org.docx4j.openpackaging.parts.PartName; 
    3536import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart; 
    36 import org.docx4j.openpackaging.parts.relationships.Relationship; 
    3737import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    38 import org.docx4j.openpackaging.parts.relationships.TargetMode; 
     38import org.docx4j.relationships.Relationships; 
     39import org.docx4j.relationships.Relationship; 
    3940 
    4041/** 
     
    207208         throws Docx4JException { 
    208209                 
    209                 for (Iterator it = rp.iterator(); it.hasNext(); ) { 
    210                         Relationship r = (Relationship)it.next(); 
    211                         log.info("For Relationship Id=" + r.getId() + " Source is " + r.getSource().getPartName() + ", Target is " + r.getTargetURI() ); 
    212                          
    213                         if (!r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     210//              for (Iterator it = rp.iterator(); it.hasNext(); ) { 
     211//                      Relationship r = (Relationship)it.next(); 
     212//                      log.info("For Relationship Id=" + r.getId() + " Source is " + r.getSource().getPartName() + ", Target is " + r.getTargetURI() ); 
     213 
     214                for ( Relationship r : rp.getRelationships().getRelationship() ) { 
     215                         
     216                        log.info("For Relationship Id=" + r.getId()  
     217                                        + " Source is " + rp.getSourceP().getPartName()  
     218                                        + ", Target is " + r.getTarget() ); 
     219                 
     220//                      if (!r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     221                        if (r.getTargetMode() != null 
     222                                        && r.getTargetMode().equals("External") ) { 
    214223                                 
    215224                                // ie its EXTERNAL 
     
    217226                                // there is just the relationship. 
    218227 
    219                                 log.warn("Encountered external resource " + r.getTargetURI()  
    220                                                    + " of type " + r.getRelationshipType() ); 
     228                                log.warn("Encountered external resource " + r.getTarget()  
     229                                                   + " of type " + r.getType() ); 
    221230                                 
    222231                                // So 
     
    225234                         
    226235                        try { 
    227                                 String resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString(); 
    228  
     236                                //String resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString(); 
     237 
     238                                String resolvedPartUri = URIHelper.resolvePartUri(rp.getSourceURI(), new URI(r.getTarget() ) ).toString();               
     239                                 
    229240                                // Now drop leading "/' 
    230241                                resolvedPartUri = resolvedPartUri.substring(1);                          
  • trunk/docx4j/src/main/java/org/docx4j/customxml/ObjectFactory.java

    r517 r532  
     1/* 
     2 *  Copyright 2007-2008, Plutext Pty Ltd. 
     3 *    
     4 *  This file is part of docx4j. 
     5 
     6    docx4j is licensed under the Apache License, Version 2.0 (the "License");  
     7    you may not use this file except in compliance with the License.  
     8 
     9    You may obtain a copy of the License at  
     10 
     11        http://www.apache.org/licenses/LICENSE-2.0  
     12 
     13    Unless required by applicable law or agreed to in writing, software  
     14    distributed under the License is distributed on an "AS IS" BASIS,  
     15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
     16    See the License for the specific language governing permissions and  
     17    limitations under the License. 
     18 
     19 */ 
     20 
    121 
    222package org.docx4j.customxml; 
  • trunk/docx4j/src/main/java/org/docx4j/customxml/SchemaLibrary.java

    r517 r532  
     1/* 
     2 *  Copyright 2007-2008, Plutext Pty Ltd. 
     3 *    
     4 *  This file is part of docx4j. 
     5 
     6    docx4j is licensed under the Apache License, Version 2.0 (the "License");  
     7    you may not use this file except in compliance with the License.  
     8 
     9    You may obtain a copy of the License at  
     10 
     11        http://www.apache.org/licenses/LICENSE-2.0  
     12 
     13    Unless required by applicable law or agreed to in writing, software  
     14    distributed under the License is distributed on an "AS IS" BASIS,  
     15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
     16    See the License for the specific language governing permissions and  
     17    limitations under the License. 
     18 
     19 */ 
     20 
    121 
    222package org.docx4j.customxml; 
  • trunk/docx4j/src/main/java/org/docx4j/customxml/package-info.java

    r517 r532  
     1/* 
     2 *  Copyright 2007-2008, Plutext Pty Ltd. 
     3 *    
     4 *  This file is part of docx4j. 
     5 
     6    docx4j is licensed under the Apache License, Version 2.0 (the "License");  
     7    you may not use this file except in compliance with the License.  
     8 
     9    You may obtain a copy of the License at  
     10 
     11        http://www.apache.org/licenses/LICENSE-2.0  
     12 
     13    Unless required by applicable law or agreed to in writing, software  
     14    distributed under the License is distributed on an "AS IS" BASIS,  
     15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
     16    See the License for the specific language governing permissions and  
     17    limitations under the License. 
     18 
     19 */ 
     20 
    121@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.openxmlformats.org/schemaLibrary/2006/main", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) 
    222package org.docx4j.customxml; 
  • trunk/docx4j/src/main/java/org/docx4j/jaxb/Context.java

    r511 r532  
    3131        public static JAXBContext jcDocPropsExtended; 
    3232        public static JAXBContext jcXmlPackage; 
     33        public static JAXBContext jcRelationships; 
    3334         
    3435        static { 
     
    4142                        jcDocPropsExtended = JAXBContext.newInstance("org.docx4j.docProps.extended"); 
    4243                        jcXmlPackage = JAXBContext.newInstance("org.docx4j.xmlPackage"); 
     44                        jcRelationships = JAXBContext.newInstance("org.docx4j.relationships"); 
    4345                } catch (Exception ex) { 
    4446                        ex.printStackTrace(); 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromJCR.java

    r350 r532  
    5757import org.docx4j.openpackaging.parts.PartName; 
    5858import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart; 
    59 import org.docx4j.openpackaging.parts.relationships.Relationship; 
    6059import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    61 import org.docx4j.openpackaging.parts.relationships.TargetMode; 
     60import org.docx4j.relationships.Relationships; 
     61import org.docx4j.relationships.Relationship; 
    6262 
    6363import org.docx4j.openpackaging.exceptions.Docx4JException; 
     
    247247                         
    248248 
    249                         return new RelationshipsPart(p, new PartName("/" + partName), is ); 
     249                        //return new RelationshipsPart(p, new PartName("/" + partName), is ); 
     250                         
     251                        RelationshipsPart rp = new RelationshipsPart(new PartName("/" + partName) ); 
     252                        rp.setSourceP(p); 
     253                        rp.unmarshal(is); 
     254                        return rp; 
     255                         
    250256                         
    251257                } catch (Exception e) { 
     
    412418                Package pkg = source.getPackage();               
    413419                 
    414                 for (Iterator it = rp.iterator(); it.hasNext(); ) { 
    415                         Relationship r = (Relationship)it.next(); 
     420//              for (Iterator it = rp.iterator(); it.hasNext(); ) { 
     421//                      Relationship r = (Relationship)it.next(); 
     422//                      log.info("For Relationship Id=" + r.getId()  
     423//                                      + " Source is " + r.getSource().getPartName()  
     424//                                      + ", Target is " + r.getTargetURI() ); 
     425//                      try {                            
     426//                              getPart(jcrSession, docxNode, pkg, rp, r); 
     427//                      } catch (Exception e) { 
     428//                              throw new Docx4JException("Failed to add parts from relationships", e); 
     429//                      } 
     430//              } 
     431                 
     432                 
     433                for ( Relationship r : rp.getRelationships().getRelationship() ) { 
     434                         
    416435                        log.info("For Relationship Id=" + r.getId()  
    417                                         + " Source is " + r.getSource().getPartName()  
    418                                         + ", Target is " + r.getTargetURI() ); 
     436                                        + " Source is " + rp.getSourceP().getPartName()  
     437                                        + ", Target is " + r.getTarget() ); 
    419438                        try {                            
    420439                                getPart(jcrSession, docxNode, pkg, rp, r); 
     
    423442                        } 
    424443                } 
    425                  
    426444                 
    427445        } 
     
    444462        public void getPart(Session jcrSession, Node docxNode,  
    445463                        Package pkg, RelationshipsPart rp, Relationship r)       
    446                         throws Docx4JException, RepositoryException, InvalidFormatException { 
     464                        throws Docx4JException, RepositoryException, InvalidFormatException, URISyntaxException { 
    447465                 
    448466                Base source = null; 
    449467                String resolvedPartUri = null; 
    450468                 
    451                 if (r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     469                if (r.getTargetMode() == null 
     470                                || !r.getTargetMode().equals("External") ) { 
    452471                         
    453472                        // Usual case 
    454473                 
    455                         source = r.getSource(); 
    456                         resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString();              
     474                        source = rp.getSourceP(); 
     475                        resolvedPartUri = URIHelper.resolvePartUri(rp.getSourceURI(), new URI(r.getTarget() ) ).toString();              
    457476         
    458477                        // Now drop leading "/' 
     
    472491                         */ 
    473492 
    474                         log.warn("Encountered external resource " + r.getTargetURI()  
    475                                            + " of type " + r.getRelationshipType() ); 
     493                        log.warn("Encountered external resource " + r.getTarget()  
     494                                           + " of type " + r.getType() ); 
    476495                         
    477496                        // As of 1 May 2008, we don't do anything with these yet. 
     
    486505                } 
    487506                 
    488                 String relationshipType = r.getRelationshipType();               
     507                String relationshipType = r.getType();           
    489508                 
    490509                Part part = getRawPart(jcrSession, nodeMapper, docxNode, ctm, resolvedPartUri); 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromZipFile.java

    r350 r532  
    2626import java.io.IOException; 
    2727import java.io.InputStream; 
     28import java.net.URI; 
    2829import java.net.URISyntaxException; 
    2930import java.util.Enumeration; 
     
    4647import org.docx4j.openpackaging.parts.PartName; 
    4748import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart; 
    48 import org.docx4j.openpackaging.parts.relationships.Relationship; 
    4949import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    50 import org.docx4j.openpackaging.parts.relationships.TargetMode; 
     50import org.docx4j.relationships.Relationships; 
     51import org.docx4j.relationships.Relationship; 
    5152 
    5253import org.dom4j.Document; 
     
    197198//              return new RelationshipsPart( p, new PartName("/" + partName), contents );       
    198199                 
    199                 RelationshipsPart thePart = null; 
     200                RelationshipsPart rp = null; 
    200201                 
    201202                InputStream is = null; 
    202203                try { 
    203204                        is =  getInputStreamFromZippedPart( zf,  partName); 
    204                         thePart = new RelationshipsPart( p, new PartName("/" + partName), is ); 
     205                        //thePart = new RelationshipsPart( p, new PartName("/" + partName), is ); 
     206                        rp = new RelationshipsPart(new PartName("/" + partName) ); 
     207                        rp.setSourceP(p); 
     208                        rp.unmarshal(is); 
    205209                         
    206210                } catch (Exception e) { 
     
    218222                } 
    219223                 
    220                 return thePart; 
     224                return rp; 
    221225        // debugPrint(contents); 
    222226        // TODO - why don't any of the part names in this document start with "/"? 
     
    270274                Package pkg = source.getPackage();                               
    271275                 
    272                 for (Iterator it = rp.iterator(); it.hasNext(); ) { 
    273                         Relationship r = (Relationship)it.next(); 
    274                         log.info("For Relationship Id=" + r.getId() + " Source is "  
    275                                         + r.getSource().getPartName()  
    276                                         + ", Target is " + r.getTargetURI() ); 
    277                         try { 
    278                                  
     276//              for (Iterator it = rp.iterator(); it.hasNext(); ) { 
     277//                      Relationship r = (Relationship)it.next(); 
     278//                      log.info("For Relationship Id=" + r.getId() + " Source is "  
     279//                                      + r.getSource().getPartName()  
     280//                                      + ", Target is " + r.getTargetURI() ); 
     281//                      try { 
     282//                               
     283//                              getPart(zf, pkg, rp, r); 
     284//                               
     285//                      } catch (Exception e) { 
     286//                              throw new Docx4JException("Failed to add parts from relationships", e); 
     287//                      } 
     288//              } 
     289                 
     290                for ( Relationship r : rp.getRelationships().getRelationship() ) { 
     291                         
     292                        log.info("For Relationship Id=" + r.getId()  
     293                                        + " Source is " + rp.getSourceP().getPartName()  
     294                                        + ", Target is " + r.getTarget() ); 
     295                        try {                            
    279296                                getPart(zf, pkg, rp, r); 
    280                                  
    281297                        } catch (Exception e) { 
    282298                                throw new Docx4JException("Failed to add parts from relationships", e); 
     
    304320//                      Package pkg, String resolvedPartUri, String relationshipType) 
    305321        private void getPart(ZipFile zf, Package pkg, RelationshipsPart rp, Relationship r) 
    306                         throws Docx4JException, InvalidFormatException { 
     322                        throws Docx4JException, InvalidFormatException, URISyntaxException { 
    307323                 
    308324                Base source = null; 
    309325                String resolvedPartUri = null; 
    310326                 
    311                 if (r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     327                if (r.getTargetMode() == null 
     328                                || !r.getTargetMode().equals("External") ) { 
    312329                         
    313330                        // Usual case 
    314331                         
    315                         source = r.getSource(); 
    316                         resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString();              
     332                        source = rp.getSourceP(); 
     333                        resolvedPartUri = URIHelper.resolvePartUri(rp.getSourceURI(), new URI(r.getTarget() ) ).toString();              
    317334 
    318335                        // Now drop leading "/' 
     
    335352                         */ 
    336353 
    337                         log.warn("Encountered external resource " + r.getTargetURI()  
    338                                            + " of type " + r.getRelationshipType() ); 
     354                        log.warn("Encountered external resource " + r.getTarget()  
     355                                           + " of type " + r.getType() ); 
    339356                         
    340357                        // As of 1 May 2008, we don't do anything with these yet. 
     
    349366                } 
    350367                 
    351                 String relationshipType = r.getRelationshipType();               
     368                String relationshipType = r.getType();           
    352369                         
    353370                Part part = getRawPart(zf, ctm, resolvedPartUri); 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/SaveToJCR.java

    r460 r532  
    2525import java.io.InputStream; 
    2626import java.io.IOException; 
     27import java.net.URI; 
    2728 
    2829import java.util.Iterator; 
     
    5657import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart; 
    5758import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; 
    58 import org.docx4j.openpackaging.parts.relationships.Relationship; 
    5959import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    60 import org.docx4j.openpackaging.parts.relationships.TargetMode; 
     60import org.docx4j.relationships.Relationships; 
     61import org.docx4j.relationships.Relationship; 
    6162 
    6263import org.docx4j.openpackaging.exceptions.Docx4JException; 
     
    140141                        // TODO - replace with saveRawXmlPart(baseNode, rp) 
    141142                        // once we know that partName resolves correctly 
    142                         saveRawXmlPart(baseNode, partName, rp.getW3cDocument() ); 
     143//                      saveRawXmlPart(baseNode, partName, rp.getW3cDocument() ); 
     144                        saveRawXmlPart(baseNode, rp ); 
    143145                         
    144146                         
     
    401403                        Node baseNode, RelationshipsPart rp )  throws Docx4JException  { 
    402404                 
    403                 for (Iterator it = rp.iterator(); it.hasNext(); ) { 
    404                         Relationship r = (Relationship)it.next(); 
     405//              for (Iterator it = rp.iterator(); it.hasNext(); ) { 
     406//                      Relationship r = (Relationship)it.next(); 
     407//                      log.info("For Relationship Id=" + r.getId()  
     408//                                      + " Source is " + r.getSource().getPartName()  
     409//                                      + ", Target is " + r.getTargetURI() ); 
     410                for ( Relationship r : rp.getRelationships().getRelationship() ) { 
     411                         
    405412                        log.info("For Relationship Id=" + r.getId()  
    406                                         + " Source is " + r.getSource().getPartName()  
    407                                         + ", Target is " + r.getTargetURI() ); 
    408                          
    409                         if (!r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     413                                        + " Source is " + rp.getSourceP().getPartName()  
     414                                        + ", Target is " + r.getTarget() ); 
     415                 
     416                         
     417//                      if (!r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     418                        if (r.getTargetMode() != null 
     419                                        && r.getTargetMode().equals("External") ) { 
    410420                                 
    411421                                // ie its EXTERNAL 
     
    413423                                // there is just the relationship. 
    414424 
    415                                 log.warn("Encountered external resource " + r.getTargetURI()  
    416                                                    + " of type " + r.getRelationshipType() ); 
     425                                log.warn("Encountered external resource " + r.getTarget()  
     426                                                   + " of type " + r.getType() ); 
    417427                                 
    418428                                // So 
     
    421431                         
    422432                        try { 
    423                                 String resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString(); 
     433                                //String resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString(); 
     434 
     435                                String resolvedPartUri = URIHelper.resolvePartUri(rp.getSourceURI(), new URI(r.getTarget() ) ).toString();               
     436 
    424437                                // Now drop leading "/' 
    425438                                resolvedPartUri = resolvedPartUri.substring(1);                          
     
    480493                        String relPart = PartName.getRelationshipsPartName(resolvedPartUri); 
    481494                        log.info("Found relationships " + relPart ); 
    482                         saveRawXmlPart(baseNode,  relPart, rrp.getW3cDocument() ); 
     495                         
     496                        //saveRawXmlPart(baseNode,  relPart, rrp.getW3cDocument() ); 
     497                        saveRawXmlPart(baseNode,  rrp ); 
     498                         
    483499                        log.info("Recursing ... " ); 
    484500                        addPartsFromRelationships( baseNode, rrp ); 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/SaveToZipFile.java

    r466 r532  
    2828import java.io.InputStream; 
    2929import java.io.OutputStream; 
     30import java.net.URI; 
    3031import java.util.Enumeration; 
    3132import java.util.Iterator; 
     
    4243import org.docx4j.openpackaging.parts.PartName; 
    4344import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart; 
    44 import org.docx4j.openpackaging.parts.relationships.Relationship; 
    4545import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    46 import org.docx4j.openpackaging.parts.relationships.TargetMode; 
     46import org.docx4j.relationships.Relationships; 
     47import org.docx4j.relationships.Relationship; 
     48 
    4749import org.dom4j.Document; 
    4850import org.dom4j.DocumentException; 
     
    238240         throws Docx4JException { 
    239241                 
    240                 for (Iterator it = rp.iterator(); it.hasNext(); ) { 
    241                         Relationship r = (Relationship)it.next(); 
    242                         log.info("For Relationship Id=" + r.getId() + " Source is " + r.getSource().getPartName() + ", Target is " + r.getTargetURI() ); 
    243                          
    244                         if (!r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     242//              for (Iterator it = rp.iterator(); it.hasNext(); ) { 
     243//                      Relationship r = (Relationship)it.next(); 
     244//                      log.info("For Relationship Id=" + r.getId() + " Source is " + r.getSource().getPartName() + ", Target is " + r.getTargetURI() ); 
     245                for ( Relationship r : rp.getRelationships().getRelationship() ) { 
     246                         
     247                        log.info("For Relationship Id=" + r.getId()  
     248                                        + " Source is " + rp.getSourceP().getPartName()  
     249                                        + ", Target is " + r.getTarget() ); 
     250                         
     251//                      if (!r.getTargetMode().equals(TargetMode.INTERNAL) ) { 
     252                        if (r.getTargetMode() != null 
     253                                        && r.getTargetMode().equals("External") ) { 
    245254                                 
    246255                                // ie its EXTERNAL 
     
    248257                                // there is just the relationship. 
    249258 
    250                                 log.warn("Encountered external resource " + r.getTargetURI()  
    251                                                    + " of type " + r.getRelationshipType() ); 
     259                                log.warn("Encountered external resource " + r.getTarget()  
     260                                                   + " of type " + r.getType() ); 
    252261                                 
    253262                                // So 
     
    256265                         
    257266                        try { 
    258                                 String resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString(); 
    259  
     267                                //String resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString(); 
     268 
     269                                String resolvedPartUri = URIHelper.resolvePartUri(rp.getSourceURI(), new URI(r.getTarget() ) ).toString();               
     270                                 
    260271                                // Now drop leading "/' 
    261272                                resolvedPartUri = resolvedPartUri.substring(1);                          
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/relationships/RelationshipsPart.java

    r511 r532  
    5151package org.docx4j.openpackaging.parts.relationships; 
    5252 
     53import javax.xml.bind.JAXBException; 
     54import javax.xml.bind.Unmarshaller; 
     55 
     56import org.docx4j.relationships.Relationships; 
     57import org.docx4j.relationships.Relationship; 
     58 
     59import org.docx4j.jaxb.Context; 
     60import org.docx4j.openpackaging.parts.JaxbXmlPart; 
     61 
    5362import java.io.InputStream; 
    5463import java.net.URI; 
    5564import java.net.URISyntaxException; 
    56 import java.util.ArrayList; 
    57 import java.util.Iterator; 
    58 import java.util.TreeMap; 
    59 import java.util.zip.ZipOutputStream; 
    6065 
    6166import org.apache.log4j.Logger; 
     
    7176import org.docx4j.openpackaging.parts.PartName; 
    7277 
    73 import org.docx4j.openpackaging.parts.Dom4jXmlPart; 
    74  
    75 import org.dom4j.Attribute; 
    76 import org.dom4j.Document; 
    77 import org.dom4j.DocumentHelper; 
    78 import org.dom4j.Element; 
    79 import org.dom4j.Namespace; 
    80 import org.dom4j.QName; 
    81 import org.dom4j.io.SAXReader; 
    82 //import org.openxml4j.opc.PackageAccess; 
     78 
    8379 
    8480 
     
    9187 * @version 0.1 
    9288 */ 
    93 public final class RelationshipsPart extends Dom4jXmlPart implements 
    94                 Iterable<Relationship> { 
    95  
     89public final class RelationshipsPart extends JaxbXmlPart {  
     90        // implements Iterable<Relationship> { 
     91 
     92        private static Logger logger = Logger.getLogger(RelationshipsPart.class); 
     93         
    9694        /* Example: 
    9795         *  
     
    142140         */ 
    143141         
    144          
    145         private static Logger logger = Logger.getLogger(RelationshipsPart.class); 
    146  
    147         /** 
    148          * Package relationships ordered by ID. 
    149          */ 
    150         private TreeMap<String, Relationship> relationshipsByID; 
    151  
    152         /** 
    153          * Package relationships ordered by type. 
    154          */ 
    155         private TreeMap<String, Relationship> relationshipsByType; 
    156  
    157  
     142        /** 
     143         * Constructor. 
     144         */ 
     145        public RelationshipsPart(PartName partName) throws InvalidFormatException { 
     146                super(partName); 
     147                init(); 
     148        } 
     149 
     150        public RelationshipsPart() throws InvalidFormatException { 
     151                super(new PartName("/rels/.rels")); 
     152                init(); 
     153        } 
     154         
     155        public void init() {             
     156                // Used if this Part is added to [Content_Types].xml  
     157                setContentType(new  org.docx4j.openpackaging.contenttype.ContentType(  
     158                                org.docx4j.openpackaging.contenttype.ContentTypes.RELATIONSHIPS_PART)); 
     159 
     160                setJAXBContext(Context.jcRelationships); 
     161                                 
     162        } 
     163         
     164        private Relationships relationships; 
     165        public Relationships getRelationships() { 
     166                return relationships; 
     167        } 
     168 
     169        public void setRelationships(Relationships relationships) { 
     170                this.relationships = relationships; 
     171        }        
     172 
     173        // NB partName is the partName of this relationship part, 
     174        // not the source Part.  sourceP above has the  
     175        // sourcePartName, which will be required in order to resolve  
     176        // relative targets 
     177         
    158178        /** 
    159179         * Source part for these relationships 
     
    164184                return sourceP; 
    165185        } 
     186        public void setSourceP( Base sourcePart) { 
     187                sourceP = sourcePart; 
     188        } 
     189         
     190        public URI getSourceURI() { 
     191                if (sourceP == null) { 
     192                        return URIHelper.PACKAGE_ROOT_URI; 
     193                } 
     194                return sourceP.getPartName().getURI(); 
     195        } 
     196         
    166197         
    167198        /** This Relationship Part is the package relationship part 
     
    172203        } 
    173204 
    174 //      public void setPackageRelationshipPart(boolean isPackageRelationshipPart) { 
    175 //              this.isPackageRelationshipPart = isPackageRelationshipPart; 
    176 //      } 
    177          
    178  
    179         /** 
    180          * Constructor. 
    181          *  
    182          * DO NOT USE.  Doesn't set source Part! 
    183          */ 
    184         public RelationshipsPart(PartName partName) throws InvalidFormatException { 
    185                 super(partName); 
    186                 // NB partName is the partName of this relationship part, 
    187                 // not the source Part.  sourceP above has the  
    188                 // sourcePartName, which will be required in order to resolve  
    189                 // relative targets 
    190                 init(); 
    191                  
    192                 //throw new InvalidFormatException(); 
    193         } 
    194205 
    195206        /** 
     
    217228                        // in this class. 
    218229                 
    219         } 
    220          
    221          
    222         /** 
    223          * Constructor.  Parses the .rels XML document. 
    224          *  
    225          * @param partName 
    226          *            The part name, relative to the parent Package root. 
    227          * @param contents 
    228          *            The XML Document contents of the part. 
    229          * @throws InvalidFormatException 
    230          *             If the specified URI is not valid. 
    231          */ 
    232         public RelationshipsPart(Base sourceP, PartName partName, InputStream in) 
    233                         throws InvalidFormatException { 
    234                 super(partName); 
    235                 setDocument(in); 
    236                 this.sourceP = sourceP; 
    237                 init(); 
    238                 Element root = document.getRootElement();                
    239                 parseRelationshipsDocument(root); 
    240                  
    241 //              this.container = (Package) pack; 
    242 //              isRelationshipPart = partName.isRelationshipPartURI(); 
    243         } 
    244  
    245         // This constructor used when input is a Word 2007 Xml Package file 
    246         public RelationshipsPart(Base sourceP, PartName partName, Element root) 
    247                         throws InvalidFormatException { 
    248                  
    249                 super(partName); 
    250                  
    251                 // setDocument(in);  // nb - not set 
    252                 this.sourceP = sourceP; 
    253                 init(); 
    254                 parseRelationshipsDocument(root); 
    255  
    256                 // this.container = (Package) pack; 
    257                 // isRelationshipPart = partName.isRelationshipPartURI(); 
    258         } 
    259          
    260          
    261         private void init() { 
    262                  
    263                 setContentType(new  org.docx4j.openpackaging.contenttype.ContentType(  
    264                                 org.docx4j.openpackaging.contenttype.ContentTypes.RELATIONSHIPS_PART)); 
    265                  
    266                 relationshipsByID = new TreeMap<String, Relationship>(); 
    267                 relationshipsByType = new TreeMap<String, Relationship>();               
     230                 
     231                // TODO - create jaxbElement|relationships from factory? 
     232                 
    268233        } 
    269234         
     
    315280                } 
    316281                 
    317                 log.info(" source is  " + r.getSourceURI() ); 
    318         log.info(id + " points to " + r.getTargetURI()); 
     282                log.info(" source is  " + sourceP.getPartName().toString() ); 
     283        log.info(id + " points to " + r.getTarget()); 
    319284        // eg rId1 points to fonts/font1.odttf 
     285                         
     286                URI uri = null; 
     287 
     288                try { 
     289                        uri = org.docx4j.openpackaging.URIHelper 
     290                                        .resolvePartUri(sourceP.partName.getURI(), new URI( 
     291                                                        r.getTarget())); 
     292                } catch (URISyntaxException e) { 
     293                        log.error("Cannot convert " + r.getTarget() 
     294                                        + " in a valid relationship URI-> ignored", e); 
     295                }                
    320296         
    321         URI uri = org.docx4j.openpackaging.URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI()); 
    322                  
     297         
    323298        try { 
    324299                        return getPackage().getParts().get( new PartName(uri, true )); 
     
    355330                log.debug("Result " + result);  
    356331                 
    357                 Relationship rel = new Relationship(sourceP, result,  
    358                                 TargetMode.INTERNAL, part.getRelationshipType(), id); 
     332                org.docx4j.relationships.ObjectFactory factory = 
     333                        new org.docx4j.relationships.ObjectFactory(); 
     334                 
     335                Relationship rel = factory.createRelationship(); 
     336                relationships.getRelationship().add(rel); 
     337                 
     338                rel.setTarget(result.toString() ); 
     339                //rel.setTargetMode( TargetMode.INTERNAL ); 
     340                rel.setType( part.getRelationshipType() ); 
     341                rel.setId( id ); 
     342                 
     343                 
     344//              Relationship rel = new Relationship(sourceP, result,  
     345//                              TargetMode.INTERNAL, part.getRelationshipType(), id); 
    359346                addRelationship(rel ); 
    360347                 
     
    372359                // Make a list in order to avoid concurrent modification exception 
    373360                java.util.ArrayList<Relationship> relationshipsToGo = new java.util.ArrayList<Relationship>(); 
    374                 for (Relationship r : relationshipsByID.values() ) { 
     361                for (Relationship r : relationships.getRelationship() ) { 
    375362                        relationshipsToGo.add(r); 
    376363                } 
     
    378365                for (Relationship r : relationshipsToGo ) { 
    379366                         
    380                         String resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString(); 
    381                          
    382                         log.info("Removing part: " + resolvedPartUri); 
    383                          
    384367                        try { 
     368                                String resolvedPartUri = URIHelper.resolvePartUri( 
     369                                                getSourceURI(), new URI(r.getTarget())).toString(); 
     370 
     371                                log.info("Removing part: " + resolvedPartUri); 
     372 
    385373                                removePart(new PartName(resolvedPartUri)); 
     374                        } catch (URISyntaxException e) { 
     375                                log.error("Cannot convert " + r.getTarget() 
     376                                                + " in a valid relationship URI-> ignored", e); 
    386377                        } catch (InvalidFormatException e) { 
    387378                                // TODO Auto-generated catch block 
     
    416407                        // Throw an error if this can't be found! 
    417408                        Relationship relToBeRemoved = null; 
    418                         for (Relationship rel : relationshipsByID.values() ) { 
    419                                  
    420                                 URI resolvedTargetURI = org.docx4j.openpackaging.URIHelper.resolvePartUri(   sourceP.partName.getURI(), rel.getTargetURI() ); 
     409//                      for (Relationship rel : relationshipsByID.values() ) { 
     410                        for (Relationship rel : relationships.getRelationship() ) { 
     411                                                                 
     412                                URI resolvedTargetURI = null; 
     413 
     414                                try { 
     415                                        resolvedTargetURI = org.docx4j.openpackaging.URIHelper 
     416                                                        .resolvePartUri(sourceP.partName.getURI(), new URI( 
     417                                                                        rel.getTarget())); 
     418                                } catch (URISyntaxException e) { 
     419                                        log.error("Cannot convert " + rel.getTarget() 
     420                                                        + " in a valid relationship URI-> ignored", e); 
     421                                }                
     422 
    421423                                log.debug("Comparing " + resolvedTargetURI + " == " + partName.getName()); 
    422424                                 
    423425                                if (partName.getName().equals(resolvedTargetURI.toString()) ) { // was rel.getTargetURI() 
    424426                                         
    425                                         log.info("True - will delete relationship with target " + rel.getTargetURI()); 
     427                                        log.info("True - will delete relationship with target " + rel.getTarget()); 
    426428                                        relToBeRemoved = rel; // Avoid java.util.ConcurrentModificationException 
    427429                                        break; 
     
    455457 
    456458 
    457  
    458  
    459  
    460         /** 
    461                  * Parse the relationship part and add all relationship in this collection. 
    462                  *  
    463                  * @param relPart 
    464                  *            The package part to parse. 
    465                  * @throws InvalidFormatException 
    466                  *             Throws if the relationship part is invalid. 
    467                  */ 
    468                 private void parseRelationshipsDocument(Element root) 
    469                                 throws InvalidFormatException { 
    470                         try { 
    471                                          
    472                                 // Browse default types 
    473          
    474                                 // Check OPC compliance M4.1 rule 
    475                                 boolean fCorePropertiesRelationship = false; 
    476          
    477                                 for (Iterator i = root 
    478                                                 .elementIterator(Relationship.RELATIONSHIP_TAG_NAME);  
    479                                                 i.hasNext();) { 
    480                                         Element element = (Element) i.next(); 
    481  
    482                                         Relationship rel = new Relationship(sourceP, element, fCorePropertiesRelationship); 
    483                                          
    484                                         if (rel.getId() == null) { 
    485                                                 // Generate a unique ID if id parameter is null. 
    486                                                 int j = 0; 
    487                                                 do { 
    488                                                         rel.setId("rId" + ++j); 
    489                                                 } while (relationshipsByID.get(rel.getId()) != null); 
    490                                         } 
    491                                          
    492                                         //addRelationship(target, targetMode, type, id); 
    493                                         addRelationship(rel); 
    494                                          
    495                                 } 
    496                         } catch (Exception e) { 
    497                                 e.printStackTrace(); 
    498                                 logger.error(e); 
    499                                 throw new InvalidFormatException(e.getMessage()); 
    500                         } 
    501                 } 
    502                  
    503                 /** 
    504                  * Return an XML representation of this part. 
    505                  */ 
    506                 public Document getDocument() { 
    507                          
    508                         // Building xml 
    509                         Document xmlOutDoc = DocumentHelper.createDocument(); 
    510                         // make something like <Relationships 
    511                         // xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> 
    512                         Namespace dfNs = Namespace.get("", Namespaces.RELATIONSHIPS); 
    513                         Element root = xmlOutDoc.addElement(new QName( 
    514                                         Relationship.RELATIONSHIPS_TAG_NAME, dfNs)); 
    515  
    516                         // <Relationship 
    517                         // TargetMode="External" 
    518                         // Id="rIdx" 
    519                         // Target="http://www.custom.com/images/pic1.jpg" 
    520                         // Type="http://www.custom.com/external-resource"/> 
    521  
    522                         log.debug("Partname is " + partName); 
    523 //                      URI sourcePartURI = URIHelper 
    524 //                                      .getSourcePartUriFromRelationshipPartUri(partName.getURI()); 
    525  
    526                         for (Relationship rel : relationshipsByID.values()) { 
    527                                 // The relationship element 
    528                                 Element relElem = root 
    529                                                 .addElement(Relationship.RELATIONSHIP_TAG_NAME); 
    530                                  
    531                                 //rel.marshall(sourcePartURI, relElem); 
    532  
    533                                 rel.marshall(relElem); 
    534                                  
    535                         } 
    536  
    537                  
    538                  xmlOutDoc.normalize(); 
    539                   
    540                  return xmlOutDoc; 
    541         } 
    542  
    543459        /** 
    544460         * Add the specified relationship to the collection. 
     
    548464         */ 
    549465        public void addRelationship(Relationship rel) { 
    550                 relationshipsByID.put(rel.getId(), rel); 
    551                 relationshipsByType.put(rel.getRelationshipType(), rel); 
    552         } 
    553  
    554  
    555          
    556          
    557         /** 
    558          * Remove a relationship by its ID. 
    559          *  
    560          * @param id 
    561          *            The relationship ID to remove. 
    562          */ 
    563 //      private void removeRelationship(String id) { 
    564 //              if (relationshipsByID != null && relationshipsByType != null) { 
    565 //                      Relationship rel = relationshipsByID.get(id); 
    566 //                      if (rel != null) { 
    567 //                              relationshipsByID.remove(rel.getId()); 
    568 //                              relationshipsByType.values().remove(rel); 
    569 //                      } 
    570 //              } 
    571 //      } 
     466                 
     467                relationships.getRelationship().add(rel); 
     468        } 
     469 
    572470 
    573471        /** 
     
    580478                if (rel == null) 
    581479                        throw new IllegalArgumentException("rel"); 
    582  
    583                 relationshipsByID.values().remove(rel); 
    584                 relationshipsByType.values().remove(rel); 
    585         } 
    586  
    587         /** 
    588          * Retrieves a relationship by its index in the collection. 
    589          *  
    590          * @param index 
    591          *            Must be a value between [0-relationships_count-1] 
    592          */ 
    593         public Relationship getRelationship(int index) { 
    594                 if (index < 0 || index > relationshipsByID.values().size()) 
    595                         throw new IllegalArgumentException("index"); 
    596  
    597                 Relationship retRel = null; 
    598                 int i = 0; 
    599                 for (Relationship rel : relationshipsByID.values()) { 
    600                         if (index == i++) 
    601                                 return rel; 
    602                 } 
    603                 return retRel; 
    604         } 
     480                 
     481                relationships.getRelationship().remove(rel); 
     482 
     483        } 
     484 
    605485 
    606486        /** 
     
    612492         */ 
    613493        public Relationship getRelationshipByID(String id) { 
    614                 return relationshipsByID.get(id); 
     494                 
     495                for ( Relationship r : relationships.getRelationship()  ) { 
     496                         
     497                        if (r.getId().equals(id) ) { 
     498                                return r; 
     499                        } 
     500                         
     501                } 
     502                 
     503                return null; 
    615504        } 
    616505 
    617506        public Relationship getRelationshipByType(String type) { 
    618                 return relationshipsByType.get(type); 
     507                 
     508                for ( Relationship r : relationships.getRelationship()  ) { 
     509                         
     510                        if (r.getType().equals(type) ) { 
     511                                return r; 
     512                        } 
     513                         
     514                } 
     515                 
     516                return null; 
    619517        } 
    620518         
     
    623521         */ 
    624522        public int size() { 
    625                 return relationshipsByID.values().size(); 
     523                return relationships.getRelationship().size(); 
    626524        } 
    627525 
     
    629527         * Get this collection's iterator. 
    630528         */ 
    631         public Iterator<Relationship> iterator() { 
    632                 return relationshipsByID.values().iterator(); 
    633         } 
     529//      public Iterator<Relationship> iterator() { 
     530//              return relationshipsByID.values().iterator(); 
     531//      } 
    634532 
    635533        /** 
     
    642540         *         specified type contain in this collection. 
    643541         */ 
    644         public Iterator<Relationship> iterator(String typeFilter) { 
    645                 ArrayList<Relationship> retArr = new ArrayList<Relationship>(); 
    646                 for (Relationship rel : relationshipsByID.values()) { 
    647                         if (rel.getRelationshipType().equals(typeFilter)) 
    648                                 retArr.add(rel); 
    649                 } 
    650                 return retArr.iterator(); 
    651         } 
    652  
    653         /** 
    654          * Clear all relationships. 
    655          */ 
    656         public void clear() { 
    657                 relationshipsByID.clear(); 
    658                 relationshipsByType.clear(); 
    659         } 
    660  
    661         @Override 
    662         public String toString() { 
    663                          
    664                 String str; 
    665                 if (relationshipsByID == null) { 
    666                         str = "relationshipsByID=null"; 
    667                 } else { 
    668                         str = relationshipsByID.size() + " relationship(s) = [ \n"; 
    669                 } 
    670                  
    671                 ArrayList<Relationship> retArr = new ArrayList<Relationship>(); 
    672                 for (Relationship rel : relationshipsByID.values()) { 
    673                         str = str + rel.toString() + "\n"; 
    674                 } 
    675                  
    676 //              if ( (partName != null)) { 
    677 //                      str = str + "," + partName; 
    678 //              } else { 
    679 //                      str = str + ",relationshipPart=null"; 
     542//      public Iterator<Relationship> iterator(String typeFilter) { 
     543//              ArrayList<Relationship> retArr = new ArrayList<Relationship>(); 
     544//              for (Relationship rel : relationshipsByID.values()) { 
     545//                      if (rel.getRelationshipType().equals(typeFilter)) 
     546//                              retArr.add(rel); 
    680547//              } 
    681 // 
    682 //              // Source of this relationship 
    683 //              if ((sourcePart != null) && (sourcePart.getPartName() != null)) { 
    684 //                      str = str + "," + sourcePart.getPartName(); 
    685 //              } else { 
    686 //                      str = str + ",sourcePart=null"; 
    687 //              } 
    688 //              if (partName != null) { 
    689 //                      str = str + "," + partName; 
    690 //              } else { 
    691 //                      str = str + ",uri=null)"; 
    692 //              } 
    693                 return str + "]"; 
    694         } 
    695  
     548//              return retArr.iterator(); 
     549//      } 
     550 
     551         
     552    /** 
     553     * Unmarshal XML data from the specified InputStream and return the  
     554     * resulting content tree.  Validation event location information may 
     555     * be incomplete when using this form of the unmarshal API. 
     556     * 
     557     * <p> 
     558     * Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>. 
     559     *  
     560     * @param is the InputStream to unmarshal XML data from 
     561     * @return the newly created root object of the java content tree  
     562     * 
     563     * @throws JAXBException  
     564     *     If any unexpected errors occur while unmarshalling 
     565     */ 
     566    public Object unmarshal( java.io.InputStream is ) throws JAXBException { 
     567         
     568                try { 
     569                         
     570//                      if (jc==null) { 
     571//                              setJAXBContext(Context.jc);                              
     572//                      } 
     573                                     
     574                        Unmarshaller u = jc.createUnmarshaller(); 
     575                         
     576                        //u.setSchema(org.docx4j.jaxb.WmlSchema.schema); 
     577                        u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); 
     578 
     579                        System.out.println("unmarshalling " + this.getClass().getName() + " \n\n" );                                                                     
     580                                                 
     581                        jaxbElement = u.unmarshal( is ); 
     582                         
     583                         
     584                        System.out.println("\n\n" + this.getClass().getName() + " unmarshalled \n\n" );                                                                  
     585 
     586                } catch (Exception e ) { 
     587                        e.printStackTrace(); 
     588                } 
     589                 
     590                relationships = (Relationships)jaxbElement; 
     591                         
     592                return jaxbElement; 
     593         
     594    } 
     595 
     596         
    696597} 
Note: See TracChangeset for help on using the changeset viewer.