天道酬勤,学无止境

xsd

XSD Validation Pattern to Enforce LastName/FirstName

I need to enforce the pattern LASTNAME/FIRSTNAME Something like Smith/John. The characters can be Alphanumeric (lowercase/uppercase) also includes special characters like ë etc. Pattern: <xsd:pattern value="[a-zA-Z0-9]/[a-zA-Z0-9]"/> Basically the rules will be - Anything before the slash - Anything after the slash - Patterns like "/John", "John/" should not be allowed Thanks in advance.

2022-01-19 02:23:53    分类:问答    xsd   xsd-validation   xsd-1.1

XmlAdapter for base64Binary results in String

I've an XSD file containing this: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc" elementFormDefault="qualified" targetNamespace="http://example.org/"> <xsd:complexType name="Certificate"> <xsd:sequence> <xsd:element name="certificate" type="xsd:base64Binary"> <xsd:annotation> <xsd:appinfo> <xjc:javaType name="java.security.cert.X509Certificate" adapter="adapters.X509CertificateAdapter" /> </xsd:appinfo> </xsd:annotation> </xsd:element> </xsd:sequence> </xsd

2022-01-18 16:52:24    分类:问答    xml   jaxb   xsd   adapter   xjc

XML Regex - Negative match

I have a problem with negative lookahead in XSD pattern. When I specified: <xs:pattern value="^(?!(00|\+\d))\d{6,}$"/> then I got an error message: Value '^(?!(00|\+\d))\d{6,}$' is not a valid XML regular expression. Any idea why it does not work? In online javascript validator it works fine (e.g. here under unit tests section click on "run test"). I need to validate phone numbers. The phone number cannot include international prefixes (+\d) and (00). Thanks

2022-01-18 11:42:08    分类:问答    regex   xml   xsd

define unique constraint based on multiple elements

Here is a simplified version of my XML: <Invoice> <DataRow> <Group>ZB</Group> <Specie>M</Specie> <Length>360</Length> </DataRow> <DataRow> <Group>ZB</Group> <Specie>M</Specie> <Length>360</Length> </DataRow> </Invoice> I want this XML to be not validated, because the values of Group/Specie/Length are the same. So I want to add an unique constraint in my XSD file. I've got this for the unique constraint: <xs:unique name="specieSizeGroupLengthAssortment"> <xs:selector xpath="Invoice/DataRow"/> <xs:field xpath="@Specie"/> <xs:field xpath="@Group"/> <xs:field xpath="@Length"/> </xs:unique> However

2022-01-18 11:21:41    分类:问答    xml   xsd   unique-constraint

Import namespace - Cannot resolve the name to a(n) 'type definition' component

Context: I am generating java classes from xsd files using maven-jaxb plugin. All my .xsd files are in a single location - src/main/resource directory. Problem: Everything works fine when xsd's don't reference/import other xsd's with a different target namespace. However when the following xsd below (with targetNamespace="http://www.companyA.com/someservice") imports another xsd filename.xsd from a different namespace (namespace="http://www.companyB.com/"), I get the above error: Cannot resolve the name xxx to a(n) 'type definition' component. Edit: the element name in the current xsd file is

2022-01-18 04:51:33    分类:问答    maven   xsd   jaxb   xjc

How create references between elements in XML

Is possible do reference to an existing element in xml file? I searched on Google but have not found the answers I was hoping for. I start immediately explaining my goal: <Car id="car1"> <plate>AAA</plate> <mark>Peugeot</mark> </Car> <Truck id="truck1"> <plate>BBB</plate> <mark>Scania</mark> </Truck> <Trailer id="trailer1"> <plate>CCC</plate> <mark>Menci</mark> </Trailer> <TrailerTruck> <Truck id="truck1"/> <Trailer id="trailer1"> </TrailerTruck> ... in this way I don't duplicate nothing. Can be possible do this kind of references? If so, how? I show you my XML Schema: <?xml version="1.0"

2022-01-17 23:43:22    分类:问答    xml   xsd

MarkLogic: XQuery to Get Values from XML Documents?

I have the following XML document loaded in MarkLogic database: <x:books xmlns:x="urn:books"> <book id="bk001"> <author>Writer</author> <title>The First Book</title> <genre>Fiction</genre> <price>44.95</price> <pub_date>2000-10-01</pub_date> <review>An amazing story of nothing.</review> </book> <book id="bk002"> <author>Poet</author> <title>The Poet's First Poem</title> <genre>Poem</genre> <price>24.95</price> <review>Least poetic poems.</review> </book> </x:books> I am new to XQuery. How would I retrieve the values from the XML document as I retrieve it from a SQL database? Output: BookID |

2022-01-17 21:50:32    分类:问答    xml   xsd   xquery   marklogic   xquery-sql

Simultaneously writing and validating XML

I have a Write method that serializes objects which use XmlAttributes. It's pretty standard like so: private bool WriteXml(DirectoryInfo dir) { var xml = new XmlSerializer(typeof (Composite)); _filename = Path.Combine(dir.FullName, _composite.Symbol + ".xml"); using (var xmlFile = File.Create(_filename)) { xml.Serialize(xmlFile, _composite); } return true; } Apart from trying to read the file I have just written out (with a Schema validator), can I perform XSD validation WHILE the XML is being written? I can mess around with memory streams before writing it to disk, but it seems in .Net there

2022-01-17 13:50:48    分类:问答    c#   .net   xml   xsd

Cannot resolve the name 'repository:repositories' to a(n) 'type definition' component

I got an exception writing the applicationContext.xml: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from class path resource [META-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd; lineNumber: 18; columnNumber: 51; src-resolve: Cannot resolve the name 'repository:repositories' to a(n) 'type definition' component. After several tries I finally found the problem is that the repository:repositories resides in spring-jpa.xsd: <xsd

2022-01-17 10:22:36    分类:问答    java   spring   xsd   namespaces   spring-data-jpa

Adding Root xmlns Using XmlSerializer with WCF SOAP

I have a class file generated from an XML Schema document supplied from a third party by our customer. I should be able to use this generated class to the customer's SOAP web service, but I'm having some problems. I've created a ServiceContract interface so I can use the WCF ChannelFactory to connect to the web service, like follows: [ServiceContract(Namespace = "http://theircompany.co.uk/theirapp/v1")] [XmlSerializerFormat] public interface IWebService { [OperationContract] EPSStatus serviceNotifyDataEventSet( [XmlElement(Namespace = "http://www.thirdparty.org/thirdapp")] DataEventSet dataSet

2022-01-17 09:41:48    分类:问答    c#   xml   wcf   soap   xsd