Apache Jena - not getting the desired result - jena

I'm adding few resources and properties in a Model like this:
String xyz = "http://www.example.com/xyz";
String creator = "http://www.example.com/Harry";
String email = "http://www.example.com/harry#xyz.com";
Resource creat = m.createResource(creator);
Resource eId = m.createResource(email);
Resource res = m.createResource(xyz).addProperty(DC.creator,creat.addProperty(VCARD.EMAIL, eId));
m.write(System.out);
I'm getting this as a result:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:dc="http://purl.org/dc/elements/1.1/" >
<rdf:Description rdf:about="http://www.example.com/xyz">
<dc:creator rdf:resource="http://www.example.com/Harry"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.com/Harry">
<vcard:EMAIL rdf:resource="http://www.example.com/harry#xyz.com"/>
</rdf:Description>
</rdf:RDF>
Is there any other way by which I can get the result Like:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:dc="http://purl.org/dc/elements/1.1/" >
<rdf:Description rdf:about="http://www.example.com/xyz">
<dc:creator rdf:resource="http://www.example.com/Harry"/>
<vcard:EMAIL rdf:resource="http://www.example.com/harry#xyz.com"/>
</rdf:Description>
</rdf:RDF>

Try the RDF/XML pretty writer: Use
model.write( .... , "RDF/XML_ABBREV")
or use Turtle.

Related

SaxonApiException: The context item for axis step ./CLIENT is absent

I am trying to convert and XML to an XML using XSLT 2.0 in saxon/java. I am using a sample XML I found on stack overflow thread "Applying Muenchian grouping for a simple XML with XSLT"
However I am getting an error : XPDY0002: The context item for axis step ./CLIENT is absent.
My test XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output omit-xml-declaration="no" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="CLIENTS" name="main">
<CLIENTS>
<xsl:for-each-group select="CLIENT" group-by="NAME">
<xsl:comment><xsl:value-of select="current-grouping-key()"/> </xsl:comment>
<CLIENT>
<xsl:sequence select="NAME" />
<xsl:for-each select="current-group()">
<ACCOUNT>
<xsl:sequence select="*[not(self::NAME)]" />
</ACCOUNT>
</xsl:for-each>
</CLIENT>
</xsl:for-each-group>
</CLIENTS>
</xsl:template>
</xsl:stylesheet>
My Test XML:
<CLIENTS>
<CLIENT>
<NAME>John</NAME>
<ACCOUNT_NUMBER>1424763562761</ACCOUNT_NUMBER>
<LAST_USED>2012-10-03</LAST_USED>
<AMOUNT>5000</AMOUNT>
</CLIENT>
<CLIENT>
<NAME>John</NAME>
<ACCOUNT_NUMBER>543667543732</ACCOUNT_NUMBER>
<LAST_USED>2012-10-02</LAST_USED>
<AMOUNT>10000</AMOUNT>
</CLIENT>
</CLIENTS>
My Java ( which works with other transforms) :
void xmlXSLTParser(){
String xslFile = commonPath + "/xslt/inputPointCSVTOXML_style2.xsl";
String inputFile = "file:///" + commonPath + pointWorkFile;
String outputFile = commonPath + pointWorkFile + ".final";
try {
Processor proc = new Processor(false);
XsltCompiler comp = proc.newXsltCompiler();
XsltExecutable exp = comp.compile(new StreamSource(new File(xslFile)));
Serializer out = new Serializer();
out.setOutputProperty(Serializer.Property.METHOD, "xml");
out.setOutputProperty(Serializer.Property.INDENT, "yes");
out.setOutputFile(new File(outputFile));
XsltTransformer trans = exp.load();
trans.setInitialTemplate(new QName("main"));
//trans.setParameter(new QName("url-of-csv"),new XdmAtomicValue(inputFile));
trans.setDestination(out);
trans.transform();
System.out.println("Output written to text file");
} catch (SaxonApiException e) {
println("XSLT Error :" + e );
}
}
}
My Error in detail:
Error at char 6 in xsl:for-each-group/#select on line 10 column 59 of inputPointCSVTOXML_style2.xsl:
XPDY0002: The context item for axis step ./CLIENT is absent
XSLT Error :net.sf.saxon.s9api.SaxonApiException: The context item for axis step ./CLIENT is absent
Your Java code does not set any context item, instead it sets an initial template. So you will need to make sure you provide the input XML as the context item to the XsltTransformer, using http://saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/XsltTransformer.html#setInitialContextNode(net.sf.saxon.s9api.XdmNode) or as a Source, using http://saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/XsltTransformer.html#setSource(javax.xml.transform.Source).
So instead of trans.setInitialTemplate(new QName("main")); use trans.setSource(new StreamSource(inputFile));.

Can't authenticate using Quickbooks web connector / CFML

I am attempting to implement a Quickbooks Web connector (QBWC) in Railo 4.x
<cfcomponent output="false">
<cffunction name = "authenticate" access="remote" returntype="string">
<cfargument name = "username" type="string" required="true">
<cfargument name = "password" type = "string" required="true">
<cfset var loc = {}>
<cfset loc.retVal= []>
<cfset loc.retVal[1] = "MYSESSIONTOKEN">
<cfset loc.retVal[2] = "NONE">
<cfset loc.retVal[3] = "">
<cfset loc.retVal[4] = "">
<cfreturn loc.retVal >
</cffunction>
<cffunction name = "clientVersion" access="remote" returnType ="string">
<cfargument name = "productVersion" type="string" required="true">
<cfset var loc = {}>
<cfset loc.retVal = "">
<cfreturn loc.retVal>
</cffunction>
</cfcomponent>
This is my QWC file:
<?xml version="1.0"?>
<QBWCXML>
<AppName>QuickCellarSVC</AppName>
<AppID></AppID>
<AppURL>http://localhost:8080/QuickCellar.cfc</AppURL>
<AppDescription>Quick Cellar railo component</AppDescription>
<AppSupport>http://localhost:8080/support.cfm</AppSupport>
<UserName>Joe</UserName>
<OwnerID>{57F3B9B1-86F1-4fcc-B1EE-566DE1813D20}</OwnerID>
<FileID>{90A44FB5-33D9-4815-AC85-BC87A7E7D1EB}</FileID>
<QBType>QBFS</QBType>
<Scheduler>
<RunEveryNMinutes>2</RunEveryNMinutes>
</Scheduler>
</QBWCXML>
The QBWC trace shows the problem :
Object reference not set to an instance of an object.
More info:
StackTrace = at QBWebConnector.WebService.do_authenticate(String& ticket, String& companyFileName)
Source = QBWebConnector
I was able to drill down a little more and discover that there is a casting problem in Railo maybe?
<?xml version="1.0" encoding="UTF-8"?>
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">-<soap:Body>-
Can't cast Complex Object Type Struct to StringUse Built-In-Function "serialize(Struct):String" to create a String from Struct
Now I know some of you are thinking "just serialize" the struct. Well, there is no such function in Railo (that I know of).
Any ideas are greatly appreciated.
The first issue I see is your "authenticate" method has return type of string, but you are returning an array. If you are trying to return a string you could use return serializeJSON(loc.retVal) instead of just retVal, which would return it as a JSON formatted string.

Nokogiri get xpath from Nokogiri::XML::Element

How to get xpath for rc an element returned by search
f=File.open('/media/cc.xml')
doc = Nokogiri::XML f
rc = doc.search('realmCode')
[#<Nokogiri::XML::Element:0x15a4d714 name="realmCode" namespace=#<Nokogiri::XML::Namespace:0x15a4dafc href="urn:hl7-org:v3"> attributes=[#<Nokogiri::XML::Attr:0x15a4d5c0 name="code" value="US">]>]
Is there a way to extract xpath from rc ?
updated with xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/ccda.xsl"?>
<ClinicalDocument xmlns:sdtc="urn:hl7-org:sdtc" xmlns:vocdo="urn:hl7-org:v3/voc" xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mif="urn:hl7-org:v3/mif">
<realmCode code="US"/>
<typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
<templateId root="2.16.840.1.113883.10.20.22.1.1"/>
<templateId root="2.16.840.1.113883.10.20.22.1.2"/>
<id root="2.16.840.1.113883.19.5.99999.1" extension="Test CCDA"/>
<code codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" code="34133-9" displayName="Summarization of Episode Note"/>
<title>Continuity of Care Document (C-CDA)</title>
<effectiveTime value="20130809043133+0000"/>
<confidentialityCode codeSystem="2.16.840.1.113883.5.25" codeSystemName="HL7 Confidentiality" code="N" displayName="Normal"/>
<languageCode code="en-US"/>
<recordTarget>
<patientRole>
<id root="2.16.840.1.113883.4.6" extension="1"/>
<id root="2.16.840.1.113883.4.1" extension="123-101-5230"/>
<addr use="HP">
<streetAddressLine>1357 Amber Drive</streetAddressLine>
<city nullFlavor="UNK"/>
<state nullFlavor="UNK"/>
<postalCode>97006</postalCode>
<country nullFlavor="UNK"/>
</addr>
<telecom value="3545345" use="HP"/>
<patient>
<name use="L">
<given qualifier="BR">test</given>
<family qualifier="CL">overall</family>
<prefix qualifier="IN">Mr</prefix>
</name>
<administrativeGenderCode codeSystem="2.16.840.1.113883.5.1" codeSystemName="HL7 AdministrativeGender" code="M" displayName="Male"/>
<birthTime value="19770429"/>
<raceCode codeSystem="2.16.840.1.113883.6.238" codeSystemName="Race and Ethnicity - CDC" code="2028-9" displayName="Asian"/>
<ethnicGroupCode codeSystem="2.16.840.1.113883.6.238" codeSystemName="Race and Ethnicity - CDC" code="2135-2" displayName="Hispanic or Latino"/>
<languageCommunication>
<languageCode code="eng"/>
<preferenceInd value="true"/>
</languageCommunication>
</patient>
</patientRole>
</recordTarget>
</ClinicalDocument>
rc is not an element-it's an array of matching elements:
results = rc.map do |node|
Nokogiri::CSS.xpath_for node.css_path
end
p results
Or, if you know there is only one matching element:
xpath = Nokogiri::CSS.xpath_for rc[0].css_path
Note that xpath_for returns an array, so you will need to extract the first element of the array:
xpath.first

rdf reasoning rules via Jena

I want to express this relation: if article X has author Y, and the author has the influenceFactor medium or high(3 classes: low , medium, high) then this article is regarded as highly recommended.
(?x computer-science#hasAuthor ?y)(?y computer-science#hasInfluenceFactor computer-science#High) -> (?x computer-science#isImportant computer-science#importantfactor)
is my thought right?
here is some snippet of the ontology
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasAuthor">
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
<owl:propertyDisjointWith rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#isAuthorOf"/>
<rdfs:range>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasAuthor"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#author"/>
</owl:Restriction>
</rdfs:range>
<rdfs:domain>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasAuthor"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#article"/>
</owl:Restriction>
</rdfs:domain>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasInfluenceFactor">
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#author"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#influenceFator"/>
</owl:ObjectProperty>
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#High">
<rdf:type rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#influenceFator"/>
</owl:NamedIndividual>
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#isImportant">
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#importantFactor"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#influenceFator"/>
</owl:ObjectProperty>
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#importantFactor">
<rdf:type rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#importantFactor"/>
</owl:NamedIndividual>
sincere thanks to any viewer of my question :)
You don't need to create a rule to express your ontology, you can do it entirely in OWL. First we define an ontology based on your example, but with some new axioms. In particular, we define two new class expressions: InfluentialArticle and ImportantArticle. An influential article has high or medium impact, an important author wrote at least one influential article:
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
#prefix owl: <http://www.w3.org/2002/07/owl#>.
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
#prefix cs: <http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#>.
# properties
cs:hasAuthor
a owl:ObjectProperty ;
rdfs:domain cs:Article ;
rdfs:range cs:Author .
cs:wrote
a owl:ObjectPropert ;
owl:inverseOf cs:hasAuthor .
# classes
cs:hasInfluenceFactor
a owl:ObjectProperty ;
rdfs:domain cs:Article ;
rdfs:range cs:InfluenceFactor .
cs:InfluenceFactor
owl:equivalentClass
[a owl:Class ;
owl:oneOf ( cs:high cs:medium cs:low )
].
cs:Author a owl:Class.
cs:Article a owl:Class.
# axioms
# an influential article has a high or medium impact
cs:InfluentialArticle
rdfs:subClassOf cs:Article ;
owl:equivalentClass [
owl:unionOf (
[a owl:Restriction ;
owl:onProperty cs:hasInfluenceFactor ;
owl:hasValue cs:high]
[a owl:Restriction ;
owl:onProperty cs:hasInfluenceFactor ;
owl:hasValue cs:medium
]
)
].
# an important author wrote an influential article
cs:ImportantAuthor
rdfs:subClassOf cs:Author ;
owl:equivalentClass [
a owl:Restriction ;
owl:onProperty cs:wrote ;
owl:someValuesFrom cs:InfluentialArticle
].
# individuals
# fred wrote a lousy paper
cs:fred
a cs:Author.
cs:article1
a cs:Article ;
cs:hasInfluenceFactor cs:low ;
cs:hasAuthor cs:fred.
# jane wrote a good paper
cs:jane
a cs:Author.
cs:article2
a cs:Article ;
cs:hasInfluenceFactor cs:high ;
cs:hasAuthor cs:jane.
Now we can write some Jena code to load this ontology and process it with a built-in reasoner:
package examples;
import java.util.Iterator;
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
public class ReasonerExample
{
String NS = "http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#";
public static void main( String[] args ) {
new ReasonerExample().run();
}
public void run() {
OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF );
FileManager.get().readModel( m, "src/main/resources/comp-sci.ttl" );
// list all authors
System.out.println( "All authors:" );
OntClass author = m.getOntClass( NS + "Author" );
for (Iterator<? extends OntResource> i = author.listInstances(); i.hasNext(); ) {
System.out.println( " " + i.next().getURI() );
}
// list high impact authors
OntClass importantAuthor = m.getOntClass( NS + "ImportantAuthor" );
System.out.println( "Important authors:" );
for (Iterator<? extends OntResource> i = importantAuthor.listInstances(); i.hasNext(); ) {
System.out.println( " " + i.next().getURI() );
}
}
}
Which gives the following output:
All authors:
http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#jane
http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#fred
Important authors:
http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#jane
Note I also fixed your names to use OWL conventions: leading capital letter for classes, lower case for everything else. I also simplified the domain and range constraints, which were a bit weird.
Update
Following a comment from the original poster, I translated the ontology to RDF/XML using Jena's rdfcat tool as follows:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cs="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Class rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Article"/>
<owl:Class rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Author"/>
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasAuthor">
<rdfs:domain rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Article"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Author"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasInfluenceFactor">
<rdfs:domain rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Article"/>
<rdfs:range>
<rdf:Description rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#InfluenceFactor">
<owl:equivalentClass>
<owl:Class>
<owl:oneOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#high"/>
<rdf:Description rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#medium"/>
<rdf:Description rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#low"/>
</owl:oneOf>
</owl:Class>
</owl:equivalentClass>
</rdf:Description>
</rdfs:range>
</owl:ObjectProperty>
<rdf:Description rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#ImportantAuthor">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Author"/>
<owl:equivalentClass>
<owl:Restriction>
<owl:onProperty>
<owl:ObjectPropert rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#wrote">
<owl:inverseOf rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasAuthor"/>
</owl:ObjectPropert>
</owl:onProperty>
<owl:someValuesFrom>
<rdf:Description rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#InfluentialArticle">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#Article"/>
<owl:equivalentClass rdf:parseType="Resource">
<owl:unionOf rdf:parseType="Collection">
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasInfluenceFactor"/>
<owl:hasValue rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#high"/>
</owl:Restriction>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#hasInfluenceFactor"/>
<owl:hasValue rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#medium"/>
</owl:Restriction>
</owl:unionOf>
</owl:equivalentClass>
</rdf:Description>
</owl:someValuesFrom>
</owl:Restriction>
</owl:equivalentClass>
</rdf:Description>
<cs:Article rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#article2">
<cs:hasInfluenceFactor rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#high"/>
<cs:hasAuthor>
<cs:Author rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#jane"/>
</cs:hasAuthor>
</cs:Article>
<cs:Article rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#article1">
<cs:hasInfluenceFactor rdf:resource="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#low"/>
<cs:hasAuthor>
<cs:Author rdf:about="http://www.semanticweb.org/aero/ontologies/2013/1/computer-science#fred"/>
</cs:hasAuthor>
</cs:Article>
</rdf:RDF>

libxml2 xml parsing issue

I have an xml file which i create myself.
<?xml version='1.0' encoding='utf-8' ?>
<Root>
<ChildElements>
<type name='xx' attr='false'>
<child id='1' regex='^[0-9]{11}$'>
<BBB>
<node1 name='aaa' regex='\w{5}'/>
<node2 name='bbb' regex='\w{3}'/>
</BBB>
</child>
<child>
.
.
.
</child>
</type>
</ChildElements>
</Root>
Something like this. I want to parse it to xml document object and iterate through its nodes, I'm using libxml2 for ios.
NSString *xmlPath = [[NSBundle mainBundle] pathForResource:#"xmlcontent" ofType:#"xml"];
NSData *xmlData = [NSData dataWithContentsOfFile:xmlPath];
NSString* xml = [[NSString alloc ] initWithData:xmlData encoding:NSUTF8StringEncoding];
int size=[xml lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
xmlDocPtr docptr=xmlParseMemory([xml UTF8String], size);
but in docptr object there is only one node, which is Root node, and when I try to get Root node child nodes it returns an empty node which name is #"text".
NSXMLParser easily parses the same XML, but I don't know how to create a document and iterate through nodes by using NSXMLParser.
maybe the error is, that your XML isn't valide:
<?xml version='1.0' encoding='utf-8' ?>
<Root>
<ChildElements>
<type name='xx' attr='false' />
<child id='1' regex='^[0-9]{11}$'>
<BBB>
<node1 name='aaa' regex='w{5}' />
<node2 name='bbb' regex='w{3}' />
</BBB>
</child>
</ChildElements>
</Root>
you can validate your XML with an online XML Validator

Resources