我试图将解决方案与这里提出的类似问题结合起来,但所有问题都在非常具体的情况下进行。我的情况如下:我有一个包含一些标签的任意xml文档,让我们说 final static String urlFCM = "https://fcm.googleapis.com/fcm/send";
private static void initFCM() {
FileInputStream serviceAccount;
try {
serviceAccount = new FileInputStream("WEB-INF/Orchestram-e2e1ceeb2481.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://orchestram-cerqana.firebaseio.com/")
.build();
FirebaseApp.initializeApp(options);
} catch (Exception e) {
e.printStackTrace();
}
/// TODO:
}
public static String sendFCM(final JSONObject value, final String token, final boolean back) {
initFCM();
Message message = Message.builder()
.putData("score", "850")
.putData("time", "2:45")
.setToken(token)
.build();
try {
String response = FirebaseMessaging.getInstance().sendAsync(message).get();
} catch (Exception e) {
e.printStackTrace();
return "ERROR";
}
return "HECHO";
}
。我想要的是拆分这些标签的父元素:
INPUT:
<separator/>
输出:
<some_tag some_attr="some_value">
some text
<some_other_tag>some another text</some_other_tag>
<separator/>
some other content
</some_tag>
此外,由于Xalan用于项目
,我仅限于XSLT 1.0