File tree Expand file tree Collapse file tree 7 files changed +48
-2
lines changed 
main/java/org/apache/xmlgraphics/xmp 
test/java/org/apache/xmlgraphics/xmp Expand file tree Collapse file tree 7 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,13 @@ public void toSAX(ContentHandler handler) throws SAXException {
134134                        if  (prefix  != null ) {
135135                            handler .startPrefixMapping (prefix , ns );
136136                        }
137+ 
138+                         if  (schema  != null ) {
139+                             for  (Map .Entry <String , String > entry  : schema .getExtraNamespaces ().entrySet ()) {
140+                                 handler .startPrefixMapping (entry .getKey (), entry .getValue ());
141+                             }
142+                         }
143+ 
137144                        handler .startElement (XMPConstants .RDF_NAMESPACE ,
138145                                "Description" , "rdf:Description" , atts );
139146                        empty  = false ;
@@ -147,6 +154,12 @@ public void toSAX(ContentHandler handler) throws SAXException {
147154                if  (prefix  != null ) {
148155                    handler .endPrefixMapping (prefix );
149156                }
157+ 
158+                 if  (schema  != null ) {
159+                     for  (String  extraPrefix  : schema .getExtraNamespaces ().keySet ()) {
160+                         handler .endPrefixMapping (extraPrefix );
161+                     }
162+                 }
150163            }
151164        }
152165
Original file line number Diff line number Diff line change 1919
2020package  org .apache .xmlgraphics .xmp ;
2121
22+ import  java .util .HashMap ;
23+ import  java .util .Map ;
24+ 
2225import  org .apache .xmlgraphics .util .QName ;
2326import  org .apache .xmlgraphics .xmp .merge .MergeRuleSet ;
2427
@@ -31,6 +34,7 @@ public class XMPSchema {
3134
3235    private  String  namespace ;
3336    private  String  prefix ;
37+     private  Map <String , String > extraNamespaces  = new  HashMap <>();
3438
3539    /** 
3640     * Constructs a new XMP schema object. 
@@ -65,4 +69,13 @@ protected QName getQName(String propName) {
6569    public  MergeRuleSet  getDefaultMergeRuleSet () {
6670        return  defaultMergeRuleSet ;
6771    }
72+ 
73+     /** Returns the map of extra namespaces to by used by child properties */ 
74+     public  Map <String , String > getExtraNamespaces () {
75+         return  extraNamespaces ;
76+     }
77+ 
78+     public  void  addExtraNamespace (String  prefix , String  namespace ) {
79+         this .extraNamespaces .put (prefix , namespace );
80+     }
6881}
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ public class PDFAExtensionXMPSchema extends XMPSchema {
3131    /** Creates a new schema instance for Dublin Core. */ 
3232    public  PDFAExtensionXMPSchema () {
3333        super (XMPConstants .PDF_A_EXTENSION , "pdfaExtension" );
34+ 
35+         addExtraNamespace ("pdfaSchema" , XMPConstants .PDF_A_SCHEMA );
36+         addExtraNamespace ("pdfaProperty" , XMPConstants .PDF_A_PROPERTY );
3437    }
3538
3639    /** 
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ public void testXMPProperties() throws SAXException {
4545                + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n " 
4646                + "<rdf:RDF>\n " 
4747                + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n " 
48+                 + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n " 
49+                 + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n " 
4850                + "<rdf:Description rdf:about=\" \" >\n " 
4951                + "<xmlns:http://www.aiim.org/pdfa/ns/property#>\n " 
5052                + "<rdf:Bag>\n " 
@@ -86,6 +88,8 @@ public void testXMPPropertiesInList() throws SAXException {
8688                + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n " 
8789                + "<rdf:RDF>\n " 
8890                + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n " 
91+                 + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n " 
92+                 + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n " 
8993                + "<rdf:Description rdf:about=\" \" >\n " 
9094                + "<xmlns:http://www.aiim.org/pdfa/ns/property#>\n " 
9195                + "<rdf:Bag>\n " 
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ public void testXMPPropertyAsValue() throws Exception {
3939                + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n " 
4040                + "<rdf:RDF>\n " 
4141                + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n " 
42+                 + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n " 
43+                 + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n " 
4244                + "<rdf:Description rdf:about=\" \" >\n " 
4345                + "<xmlns:http://www.aiim.org/pdfa/ns/property#>\n " 
4446                + "<prefix1:name1>\n " 
Original file line number Diff line number Diff line change @@ -41,12 +41,13 @@ public void testPDFAExtensionElement() throws SAXException {
4141                + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n " 
4242                + "<rdf:RDF>\n " 
4343                + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n " 
44+                 + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n " 
45+                 + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n " 
4446                + "<rdf:Description rdf:about=\" \" >\n " 
4547                + "<pdfaExtension:schemas>\n " 
4648                + "<rdf:Bag>\n " 
4749                + "<rdf:li rdf:parseType=\" Resource\" >\n " 
4850                + "<pdfaSchema:schema>\n " 
49-                 + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n " 
5051                + "PDF/UA identification schema\n " 
5152                + "</pdfaSchema:schema>\n " 
5253                + "<pdfaSchema:namespaceURI>\n " 
@@ -59,7 +60,6 @@ public void testPDFAExtensionElement() throws SAXException {
5960                + "<rdf:Seq>\n " 
6061                + "<rdf:li rdf:parseType=\" Resource\" >\n " 
6162                + "<pdfaProperty:name>\n " 
62-                 + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n " 
6363                + "part\n " 
6464                + "</pdfaProperty:name>\n " 
6565                + "<pdfaProperty:valueType>\n " 
Original file line number Diff line number Diff line change 2222import  org .junit .Test ;
2323
2424import  static  org .junit .Assert .assertEquals ;
25+ import  static  org .junit .Assert .assertFalse ;
26+ import  static  org .junit .Assert .assertTrue ;
2527
2628import  org .apache .xmlgraphics .xmp .XMPConstants ;
2729
@@ -33,6 +35,15 @@ public void testPDFAExtensionSchema() {
3335
3436        assertEquals ("pdfaExtension" , schema .getPreferredPrefix ());
3537        assertEquals (XMPConstants .PDF_A_EXTENSION , schema .getNamespace ());
38+         assertFalse ("Must have the namespaces of child properties" , schema .getExtraNamespaces ().isEmpty ());
3639
40+         assertTrue ("The prefix must be the key" , schema .getExtraNamespaces ().containsKey ("pdfaSchema" ));
41+         assertTrue ("The prefix must be the key" , schema .getExtraNamespaces ().containsKey ("pdfaProperty" ));
42+ 
43+ 
44+         assertEquals ("Namespace must match the correct prefix`" , XMPConstants .PDF_A_SCHEMA ,
45+                 schema .getExtraNamespaces ().get ("pdfaSchema" ));
46+         assertEquals ("Namespace must match the correct prefix`" , XMPConstants .PDF_A_PROPERTY ,
47+                 schema .getExtraNamespaces ().get ("pdfaProperty" ));
3748    }
3849}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments