可以说我下面有一个类有getter和setter但只有默认构造函数.
注意:我不允许更改此类的结构.
class Target {
private String year;
private String month;
private String name;
private double target;
private double achieved;
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getTarget() {
return target;
}
public void setTarget(double target) { …Run Code Online (Sandbox Code Playgroud) 我有两个问题和答案
String questions[] = {
"Q1?",
"Q2?",
"Q3?"};
String answers[] = {
"A1?",
"A2?",
"A3?"};
Run Code Online (Sandbox Code Playgroud)
我曾经Collections.shuffle(Arrays.asList(questions);洗过每个阵列.如何对每个阵列进行洗牌,以便在洗牌后保持相同的顺序?
我能够将文本和段落添加到单词中,并用文本替换任何合并字段,但我需要使用docx4j添加新的合并字段来创建单词模板.我怎样才能做到这一点?
我是否wordMLPackage.getMainDocumentPart().addTargetPart(targetpart);用于添加合并字段.如果是这样的话?
编辑:
将示例单词上传到http://webapp.docx4java.org/OnlineDemo/PartsList.html和对象表示部分后,我可能需要添加org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart对象?
但我仍然不明白如何添加Mergefield.我还生成了以下xml来找到我能得到的任何线索:
<w:document xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:ns21="urn:schemas-microsoft-com:office:powerpoint" xmlns:ns23="http://schemas.microsoft.com/office/2006/coverPageProps" xmlns:dsp="http://schemas.microsoft.com/office/drawing/2008/diagram" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:odx="http://opendope.org/xpaths" xmlns:odgm="http://opendope.org/SmartArt/DataHierarchy" xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram" xmlns:ns17="urn:schemas-microsoft-com:office:excel" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:odi="http://opendope.org/components" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ns32="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:ns30="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" xmlns:ns12="http://schemas.openxmlformats.org/drawingml/2006/chartDrawing" xmlns:ns31="http://schemas.openxmlformats.org/drawingml/2006/compatibility" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:odq="http://opendope.org/questions" xmlns:ns8="http://schemas.openxmlformats.org/schemaLibrary/2006/main" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:odc="http://opendope.org/conditions" xmlns:oda="http://opendope.org/answers">
<w:body>
<w:p w:rsidR="00F66879" w:rsidP="00E80FA3" w:rsidRDefault="003B0B3A">
<w:r>
<w:t>Dear</w:t>
</w:r>
<w:r w:rsidR="00E80FA3">
<w:t xml:space="preserve"> </w:t>
</w:r>
<w:fldSimple w:instr=" MERGEFIELD lastName \* MERGEFORMAT ">
<w:r w:rsidR="005C0283">
<w:rPr>
<w:noProof/>
</w:rPr>
<w:t>«lastName»</w:t>
</w:r>
</w:fldSimple>
<w:r w:rsidR="00E80FA3">
<w:t>,</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00532EBF" w:rsidP="00E80FA3" w:rsidRDefault="00532EBF">
<w:r> …Run Code Online (Sandbox Code Playgroud) 我有一个XML文档:
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<fruits>
<fruit id="1">
<title>I like pineapples</title>
<description> a tropical plant with edible multiple fruit consisting of coalesced berries</description>
</fruit>
<fruit id="2">
<title>I like watermelons</title>
<description>has a smooth exterior rind (green, yellow and sometimes white) and a juicy, sweet interior flesh</description>
</fruit>
</fruits>
</document>
Run Code Online (Sandbox Code Playgroud)
如何检查title元素是否包含'菠萝',以便我只能显示description该特定的fruit?
这是我的XSLT转换:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
doctype-system="http://www.wapforum.org/DTD/xhtml-mobile10.dtd"/>
<xsl:template match="/">
<xsl:element name="html">
<xsl:element name="head">
<xsl:element name="title">Fruits</xsl:element>
</xsl:element>
<xsl:element …Run Code Online (Sandbox Code Playgroud) 我有以下XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="library.xsd">
<!--<!DOCTYPE library SYSTEM "library.dtd">-->
<authors>
<author aid="a1">Bill Evjen</author>
<author aid="a2">Michael Kay</author>
<author aid="a3">Kevin Goldberg</author>
<author aid="a4">Michael Morrison</author>
</authors>
<books>
<book bookID="b001" author="a2">
<title>XSLT 2.0 and XPath 2.0 Programmer's Reference</title>
<stock>4</stock>
<publisher>John Wiley</publisher>
<year>2009</year>
<use type="advanced" />
<use type="reference" />
</book>
<book bookID="b002" author="a1 a2">
<title>Professional XML (Programmer to Programmer) </title>
<stock>2</stock>
<publisher>John Wiley</publisher>
<year>2007</year>
<use type="professional" />
<use type="advanced" />
<use type="reference" />
</book>
<book bookID="b003" author="a3">
<title>XML: Visual QuickStart Guide</title>
<stock>3</stock>
<publisher>Peachpit …Run Code Online (Sandbox Code Playgroud) I am learning about Kubernetes am trying move from docker-compose to use Kubernetes but having problem with connecting to MongoDB running on localhost.
I don't have any problems connecting using following docker-compose.yaml by using 'network_mode: "host"'
//docker-compose.yaml
version: '3'
services:
eureka:
image: sage-eureka
ports:
- "8080:8080"
network_mode: "host"
Run Code Online (Sandbox Code Playgroud)
But I'm having issues in Kubernetes. I used Kompose to convert the docker-compose.
//application.properties
spring.data.mongodb.host=localhost (tried adding mongo instead of localhost when used ExternalName and ClusterIP)
spring.data.mongodb.port=27017
spring.data.mongodb.database=MyMongo
// eureka-service.yaml
apiVersion: v1 …Run Code Online (Sandbox Code Playgroud) java ×3
xml ×2
arrays ×1
collections ×1
docx4j ×1
java-8 ×1
java-stream ×1
kubectl ×1
kubernetes ×1
lambda ×1
list ×1
minikube ×1
xpath-2.0 ×1
xsd ×1
xslt ×1