小编bla*_*rno的帖子

XML中的Doctrine类继承

我正在尝试使用Doctrine 2 ORM设置类继承,但是遇到错误(即使遵循他们的示例).我正在使用Symfony 2沙箱中的控制台.这个简单的例子使用PersonEmployee类; 一个员工伸出的人.

我在尝试生成实体时遇到的错误是:

[Doctrine\ORM\Mapping\MappingException]

Entity class 'Employee' used in the discriminator map of class 'Application\MyBundle\Entity\Person' does not exist.

正在尝试的XML如下:

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xsi="http://www.w3.org/2001/XMLSchema-instance"
                  schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

<entity name="Application\MyBundle\Entity\Person" inheritance-type="SINGLE_TABLE">
    <change-tracking-policy>DEFERRED_IMPLICIT</change-tracking-policy>
    <id name="id" type="integer" column="id">
        <generator strategy="AUTO"/>
    </id>

    <discriminator-column name="discr" type="string" />

    <discriminator-map>
        <discriminator-mapping value="employee" class="Employee" />
    </discriminator-map>

    <lifecycle-callbacks/>
</entity>

</doctrine-mapping>
Run Code Online (Sandbox Code Playgroud)

雇员

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xsi="http://www.w3.org/2001/XMLSchema-instance"
                  schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

<entity name="Application\MyBundle\Entity\Employee">
    <change-tracking-policy>DEFERRED_IMPLICIT</change-tracking-policy>
    <id name="id" type="integer" column="id">
        <generator …
Run Code Online (Sandbox Code Playgroud)

xml orm symfony doctrine-orm

9
推荐指数
2
解决办法
3764
查看次数

ProcessBuilder与Runtime.exec()

我正在尝试使用Inkscape的命令行功能在Java中创建一个前端应用程序来处理批量SVG转换.我正在从https://sourceforge.net/projects/conversionsvg/获取并更新代码.原始开发人员通过Runtime.getRuntime().exec(String)处理Inkscape的方式.我遇到的问题是使用methodA和methodB之间存在一些不一致.我创建了一个简单的java测试项目来演示正在执行的不同操作.

CallerTest.java

package conversion;

import java.io.IOException;

public class CallerTest {

    static String pathToInkscape = "\"C:\\Program Files\\Inkscape\\inkscape.exe\"";  

    public static void main(String[] args) {

      ProcessBuilderCaller processBuilder = new ProcessBuilderCaller();
      RuntimeExecCaller runtimeExec = new RuntimeExecCaller();

      // methodA() uses one long command line string
      try {

        String oneLongString_ProcessBuilder = pathToInkscape + " -f \"C:\\test.svg\" -D -w 100 -h 100 -e \"C:\\ProcessBuilder-methodB.png\"";
        String oneLongString_RuntimeExec =    pathToInkscape + " -f \"C:\\test.svg\" -D -w 100 -h 100 -e \"C:\\RuntimeExec-methodA.png\"";

//        processBuilder.methodA(oneLongString_ProcessBuilder);
        runtimeExec.methodA(oneLongString_RuntimeExec);

      } …
Run Code Online (Sandbox Code Playgroud)

java external-process runtime.exec inkscape processbuilder

9
推荐指数
1
解决办法
2万
查看次数

XSD的可追溯性

我正在尝试让我的XML模式处理一些可跟踪性功能,因为我在阅读一些功能规范时收集了需求.(不适合需求管理,但至少它是一个开始.)

我正在做的是为我目前正在阅读的每个功能规范创建一个< functionalSpec>标签.我为我找到的每个要求创建了< requirement>标签.由于我希望能够跟踪需求的来源,因此我创建了一个< trace>元素,其id为< functionalSpec>元素.我希望XSD能够验证并确保我只输入现有功能规范中存在的id,而不是允许自己在< functionalSpecId>标签中输入任何普通旧文本.我的问题出现在XML Schema W3C Recommendations中文档说我想做的事是不可能的.(大约1/2路)

{selector}指定相对于正在声明的元素的实例的受限XPath([XPath])表达式.这必须标识约束适用的从属元素的节点集(即包含在声明的元素中).

我正在使用Oxygen创建这个,因为我对XSD文件相当新,它给了我以下错误:

E [Xerces] Identity Constraint error:identity constraint"KeyRef @ 1045a2"有一个keyref,它指的是超出范围的密钥或唯一.

所以我的问题是,有没有人知道一种方法,允许我通过使用XSD使用我下面的相同的XML结构?

下面是XML文件.

<?xml version="1.0" encoding="UTF-8" ?>

<srs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="srs req2.xsd"
    xmlns="srs">

<requirements>

<requirement DateCreated="2010-06-11" id="1">
    <Text>The system shall...</Text>
    <trace>
        <functionalSpecId>B010134</functionalSpecId>
    </trace>
    <revisions>
        <revision date="2010-06-11" num="0">
            <description>Initial creation.</description>
        </revision>
    </revisions>
</requirement>

</requirements>

<functionalSpecs>

    <functionalSpec id="B010134" model="Model-T">
        <trace>
            <meeting></meeting>
        </trace>
        <revisions>
            <revision date="2009-07-08" num="0">
                <description>Initial creation.</description>
            </revision>
            <detailer>Me</detailer>
            <engineer>Me</engineer> …
Run Code Online (Sandbox Code Playgroud)

xml xsd requirements traceability

5
推荐指数
1
解决办法
1387
查看次数

PHP do-while与HTML之间

我正在尝试编写PHP代码来循环遍历数组以创建HTML表.我一直在尝试做类似的事情:

<div id="results">
<table class="sortable">
    <?php $results = $statement->fetchAll(PDO::FETCH_ASSOC); ?>
    <?php do: ?>
        <tr>
            <?php for ($i = 0; $i < count($columns); $i++): ?>
                 <td><?php echo $row[$i] ?></td>
            <?php endfor; ?>
        </tr>
    <?php while (($row = next($results)) != false); ?>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)

那2个问题:

  1. 是否存在等效的do-while 语法,因为PHP中有for,ifforeach语法,您可以在其中拆分PHP代码并在其间包含HTML?

  2. 当你用PHP在中间拆分PHP代码时,这叫做什么? (如果有特殊条款)

html php

1
推荐指数
1
解决办法
6818
查看次数