1 19 package org.netbeans.modules.xslt.model.impl; 20 21 import javax.xml.namespace.QName ; 22 23 24 28 class QNameBuilder { 29 30 public static QName createQName( XslComponentImpl component , 31 XslAttributes attribute) 32 { 33 String str = component.getAttribute(attribute); 34 return createQName(component, str); 35 } 36 37 public static QName createQName( XslComponentImpl component , 38 String value ) 39 { 40 if (value == null) { 41 return null; 42 } 43 String [] splited = new String [2]; 44 splitQName( value , splited ); 45 46 String uri = component.lookupNamespaceURI( splited[0] , true ); 47 if (uri == null) { 48 return null; 49 } 50 return new QName (uri, splited[1], splited[0]); 51 } 52 53 public static void splitQName( String qName , String [] result ){ 54 assert qName!=null; 55 assert result != null; 56 String [] parts = qName.split(":"); String prefix; 58 String localName; 59 if (parts.length == 2) { 60 prefix = parts[0]; 61 localName = parts[1]; 62 } else { 63 prefix = null; 64 localName = parts[0]; 65 } 66 if ( result.length >0 ){ 67 result[0] = prefix; 68 } 69 if ( result.length >1 ){ 70 result[1]=localName; 71 } 72 } 73 } 74 | Popular Tags |