我正在我的公司创建一个新的dataexchange服务.我们想扩展在我们的core.xsd定义文件中定义的现有对象.这是我需要做的一个例子:
<xs:complexType name="parentType">
<xs:sequence>
<xs:element name="departmentName" type="core:DEPARTMENT_NAME"
minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="childType">
<xs:complexContent>
<xs:extension base="parentType">
<xs:sequence>
<xs:element name="departmentName"
type="core:DEPARTMENT_NAME"
minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)
我觉得这很有道理.我想覆盖父元素并使其成为必需.但是,有效的xml文件就是这样.现在有一个额外的部门名称!?
<childType>
<departmentName>HR</departmentName>
<departmentName>IT</departmentName>
</childType>
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能使XML文件成为:
<childType>
<departmentName>IT</departmentName>
</childType>
Run Code Online (Sandbox Code Playgroud)
谢谢,克雷格
使用xsl时我有不一致的地方,
这是xml,
<Rate>
<TotalRate>506.41</TotalRate>
<TotalTax>17</TotalTax>
<Currency>INR</Currency>
</Rate>
Run Code Online (Sandbox Code Playgroud)
和xsl,
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<TotalAmount>
<xsl:value-of select="Rate/TotalRate + Rate/TotalTax"/>
</TotalAmount>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
而输出是,
<TotalAmount xmlns:fo="http://www.w3.org/1999/XSL/Format">523.4100000000001</TotalAmount>
Run Code Online (Sandbox Code Playgroud)
但预期的o/p是,
<TotalAmount xmlns:fo="http://www.w3.org/1999/XSL/Format">523.41</TotalAmount>
Run Code Online (Sandbox Code Playgroud)
为什么o/p是523.4100000000001?如何在没有舍入的情况下获得523.41?
我的XML为我提供了分配给不同mmids的多个图像:
<Mediendaten>
<Mediendaten mmid="22404">
<url size="original">A 22404 FILE</url>
<url size="thumb">ANOTHER 22404 FILE</url>
</Mediendaten>
<Mediendaten mmid="22405">
<url size="original">A 22405 FILE</url>
<url size="thumb">ANOTHER 22405 FILE</url>
</Mediendaten>
<Mediendaten>
Run Code Online (Sandbox Code Playgroud)
我的XSLT只选择size = thumb的网址:
<xsl:template match="/Mediendaten">
<xsl:apply-templates select="Mediendaten/url">
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Mediendaten/url">
<xsl:if test="@size = 'thumb'">
<img width="280" border="0" align="left">
<xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
</img>
</xsl:if>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
但是,我只需要第一个mmid的缩略图(在本例中为22404).我无法控制mmid值.
如何停止我的模板,以便它只输出第一个mmid的拇指文件?
非常感谢您的帮助!
我有以下xsd用于我的项目我试图根据付款方式枚举属性为xmls ACH和CC制作单个xsd如果付款方式是Ach然后ACHInfo变为必需其他CreditCardInfo ..
<xs:element name="PaymentMethod">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ACH"/>
<xs:enumeration value="CreditCard"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CreditCardInfo" minOccurs="0">
<xs:complexType>
<xs:all>
<xs:element name="Cvv2No">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CardNumber">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="ACHInfo" minOccurs="0">
<xs:complexType>
<xs:all>
<xs:element name="RoutingNumber" nillable="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="AccountNumber" nillable="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
任何人都可以为我提供解决方案,根据枚举值,xsd需要更改所需的属性.
谢谢.
我有以下架构声明:
<element name="container">
<complexType>
<choice minOccurs="0" maxOccurs="unbounded">
<element name="action" minOccurs="0" maxOccurs="1" />
<element name="query" minOccurs="0" maxOccurs="unbounded" />
<element name="validator" minOccurs="0" maxOccurs="unbounded" />
</choice>
</complexType>
</element>
Run Code Online (Sandbox Code Playgroud)
我基本上想要<container>包含所需数量<query>或<validator>元素,但只包含一个<action>元素(可能没有).
据我所知,我不能把maxOccurs放在<choice>技术上,因为这个选择可以无限次地进行(由于查询和验证器上没有遮挡).
但是,这个XML在Eclipse中被认为是有效的(这可能只是Eclipse验证中的一个问题,尽管所有其他位工作正常)
<container>
<action id="action1" name="action1" />
<action id="action2" name="action2" />
<query id="query1" />
<validator id="testValidator" />
</container>
Run Code Online (Sandbox Code Playgroud)
不确定我是否遗漏了一些明显的东西.
的合金4语法允许签名声明(和其他一些东西)携带private关键字.它还允许允许规范包含表单的枚举声明
enum nephews { hughie, louis, dewey }
enum ducks { donald, daisy, scrooge, nephews }
Run Code Online (Sandbox Code Playgroud)
语言参考没有(据我所知)描述private关键字或enum构造的含义.
有文件吗?或者它们是否在语法中作为为将来的规范保留的构造?
现有的XSD代码段:
<xs:element name="searchcriteria">
<xs:complexType>
<xs:sequence>
<xs:element ref="filter"
minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Request"
type="RequestType" />
</xs:complexType>
</xs:element>
<xs:element name="filter">
<xs:complexType>
<xs:sequence>
<xs:element ref="filter"
minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="FieldName"
type="FieldNameType" />
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
...
RequestType:枚举2个值R1和R2
FieldNameType:2个值F1和F2的枚举
现在我想修改此XSD以提供以下验证:
我该如何添加此类验证?谢谢.
运行以下输入XML时
<root>
<value>false</value>
<value>true</value>
</root>
Run Code Online (Sandbox Code Playgroud)
针对以下XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="value">
<true_value/>
</xsl:template>
<xsl:template match="value[. = 'false']">
<false_value/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
我的value元素带有'false',因为它的内容改为false_value..而且所有其他value元素都变成了true_value.输出:
<?xml version="1.0" encoding="utf-8"?>
<root>
<false_value/>
<true_value/>
</root>
Run Code Online (Sandbox Code Playgroud)
但是只有当我更改模板匹配时才会出现root/value模糊的模板警告.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root/value">
<true_value/>
</xsl:template>
<xsl:template match="root/value[. = 'false']">
<false_value/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
请帮助我解释root在 …
我有一个语法,想证明它不在 LL(1) 中:
S->SA|A
A->a
Run Code Online (Sandbox Code Playgroud)
由于它是左递归文法,为了找到第一个和后续集合,我消除了左递归并得到:
S->AS'
S'->AS'|Empty
A->a
first of A={a} follow of S={$}
first of s'={a,?} follow of S'={$}
first of S={a} follow of A={a,$}
Run Code Online (Sandbox Code Playgroud)
但是当我填写解析表时,我没有得到任何包含 2 个条目的单元格。那么如何证明给定的文法不在 LL(1) 中呢?
compiler-construction parsing automation ll-grammar formal-languages
我正在编写一个 XSD 来验证一个 XML,但是当我验证这个错误时出现了:
输出 - 错误
使用 XML 模式验证当前文件:
错误:元素“{ http://www.w3.org/2001/XMLSchema-instance }Gasto”:不需要此元素。预期是(加斯托)
......我不明白这个错误
这是我的 XML 示例:
<?xml version="1.0" encoding="UTF-8"?>
<Armazem>
<Lista_Gastos xmlns:artGasto="http://www.w3.org/2001/XMLSchema-instance"
artGasto:noNamespaceSchemaLocation="TraXSD.xsd">
<artGasto:Gasto id="50">
<artGasto:nome>Robalo</artGasto:nome>
<artGasto:quantidade>1</artGasto:quantidade>
</artGasto:Gasto>
</Lista_Gastos>
</Armazem>
Run Code Online (Sandbox Code Playgroud)
这是我的 XSD 示例:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:artGasto="http://www.w3.org/2001/XMLSchema-instance">
<xsd:element name="Armazem">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Lista_Gastos"
type="TListGastos" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="TListGastos">
<xsd:sequence >
<xsd:element name="Gasto" type="TGasto"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TGasto">
<xsd:sequence >
<xsd:element name="nome" type="xsd:string" />
<xsd:element name="quantidade" type="xs:integer" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" use="required"/> …Run Code Online (Sandbox Code Playgroud) xsd ×4
xml ×3
xslt ×3
alloy ×1
automation ×1
ll-grammar ×1
parsing ×1
xpath ×1
xslt-1.0 ×1
xslt-2.0 ×1