Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Facets - dynamically updating
Facets - dynamically updating [message #70512] Mon, 30 October 2006 11:07 Go to next message
Eclipse User
Originally posted by: ashish.deshpande.cc

Hi,
I am having a problem adding/using a facet. Here's the code:

------------------------------------------------------------ -------
XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
schema.setSchemaForSchemaQNamePrefix("xsd");
schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);

XSDSimpleTypeDefinition s3 =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();

s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
"string"));

XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
facet.setLexicalValue("\\d{2}.\\d{1}");
s3.getFacetContents().add(facet);

System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));

schema.getContents().add(s3);
schema.update(true);
System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
------------------------------------------------------------ -------

No matter what I try, I cannot get the added pattern facet to print or
the literal validation to fail. What am I missing?

Thx,
-Ashish
Re: Facets - dynamically updating [message #70532 is a reply to message #70512] Mon, 30 October 2006 12:10 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000809010801070604080108
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ashish,

Until you put your schema in an XSD Resource (which calls
XSDSchema.setSchemaLocation with the URI of that resource), the schema
won't be fully type analyzed. So the minimum you need to do, short of
putting the schema in a proper resource, is to add the line:

schema.setSchemaLocation("main.xsd");


Ashish Deshpande wrote:

> Hi,
> I am having a problem adding/using a facet. Here's the code:
>
> ------------------------------------------------------------ -------
> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
> schema.setSchemaForSchemaQNamePrefix("xsd");
> schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>
> XSDSimpleTypeDefinition s3 =
> XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
>
> s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
> "string"));
>
> XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
> facet.setLexicalValue("\\d{2}.\\d{1}");
> s3.getFacetContents().add(facet);
>
> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
>
> schema.getContents().add(s3);
> schema.update(true);
> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
> ------------------------------------------------------------ -------
>
> No matter what I try, I cannot get the added pattern facet to print or
> the literal validation to fail. What am I missing?
>
> Thx,
> -Ashish



--------------000809010801070604080108
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ashish,<br>
<br>
Until you put your schema in an XSD Resource (which calls
XSDSchema.setSchemaLocation with the URI of that resource), the schema
won't be fully type analyzed.&nbsp; So the minimum you need to do, short of
putting the schema in a proper resource, is to add&nbsp; the line:<br>
<blockquote>schema.setSchemaLocation("main.xsd");<br>
</blockquote>
<br>
Ashish Deshpande wrote:
<blockquote cite="midei4mdr$2t4$1@utils.eclipse.org" type="cite">Hi,
<br>
I am having a problem adding/using a facet. Here's the code:
<br>
<br>
------------------------------------------------------------ -------
<br>
XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
<br>
schema.setSchemaForSchemaQNamePrefix("xsd");
<br>
schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <br>
XSDSimpleTypeDefinition s3 =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
<br>
&nbsp;&nbsp;&nbsp;&nbsp;
s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
"string"));
<br>
<br>
XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
<br>
facet.setLexicalValue("\\d{2}.\\d{1}");
<br>
s3.getFacetContents().add(facet);
<br>
<br>
System.out.println (s3.getFacets() + "&nbsp;&nbsp; " +
s3.isValidLiteral("abcd"));
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <br>
schema.getContents().add(s3);
<br>
schema.update(true);
<br>
System.out.println (s3.getFacets() + "&nbsp;&nbsp; " +
s3.isValidLiteral("abcd"));
<br>
------------------------------------------------------------ -------
<br>
<br>
No matter what I try, I cannot get the added pattern facet to print or
the literal validation to fail. What am I missing?
<br>
<br>
Thx,
<br>
-Ashish
<br>
</blockquote>
<br>
</body>
</html>

--------------000809010801070604080108--
Re: Facets - dynamically updating [message #70551 is a reply to message #70532] Mon, 30 October 2006 13:50 Go to previous messageGo to next message
Eclipse User
Originally posted by: ashish.deshpande.cc

Thanks Ed. I will try that.

I guess this means that there is no way to use an
XSDSimpleTypeDefinition (with a pattern facet) to assess the validity of
a literal without adding it to a schema etc.

I really just want to create a new simple type (with base "string"), add
a pattern facet, validate some literals against it and then discard this
simple type. Not that big a deal to add it to a schema etc. but I'm just
wondering.

I tried assessments but that didn't do what I wanted either.

Thx,
-Ashish


Ed Merks wrote:
> Ashish,
>
> Until you put your schema in an XSD Resource (which calls
> XSDSchema.setSchemaLocation with the URI of that resource), the schema
> won't be fully type analyzed. So the minimum you need to do, short of
> putting the schema in a proper resource, is to add the line:
>
> schema.setSchemaLocation("main.xsd");
>
>
> Ashish Deshpande wrote:
>> Hi,
>> I am having a problem adding/using a facet. Here's the code:
>>
>> ------------------------------------------------------------ -------
>> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
>> schema.setSchemaForSchemaQNamePrefix("xsd");
>> schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
>> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>>
>> XSDSimpleTypeDefinition s3 =
>> XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
>>
>> s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
>> "string"));
>>
>> XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
>> facet.setLexicalValue("\\d{2}.\\d{1}");
>> s3.getFacetContents().add(facet);
>>
>> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
>>
>> schema.getContents().add(s3);
>> schema.update(true);
>> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
>> ------------------------------------------------------------ -------
>>
>> No matter what I try, I cannot get the added pattern facet to print or
>> the literal validation to fail. What am I missing?
>>
>> Thx,
>> -Ashish
>
Re: Facets - dynamically updating [message #70570 is a reply to message #70551] Mon, 30 October 2006 16:09 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

Ashish,

Yes, you definitely need to build a full instance, i.e., a type within a
schema to get it to work.


Ashish Deshpande wrote:

> Thanks Ed. I will try that.
>
> I guess this means that there is no way to use an
> XSDSimpleTypeDefinition (with a pattern facet) to assess the validity
> of a literal without adding it to a schema etc.
>
> I really just want to create a new simple type (with base "string"),
> add a pattern facet, validate some literals against it and then
> discard this simple type. Not that big a deal to add it to a schema
> etc. but I'm just wondering.
>
> I tried assessments but that didn't do what I wanted either.
>
> Thx,
> -Ashish
>
>
> Ed Merks wrote:
>
>> Ashish,
>>
>> Until you put your schema in an XSD Resource (which calls
>> XSDSchema.setSchemaLocation with the URI of that resource), the
>> schema won't be fully type analyzed. So the minimum you need to do,
>> short of putting the schema in a proper resource, is to add the line:
>>
>> schema.setSchemaLocation("main.xsd");
>>
>>
>> Ashish Deshpande wrote:
>>
>>> Hi,
>>> I am having a problem adding/using a facet. Here's the code:
>>>
>>> ------------------------------------------------------------ -------
>>> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
>>> schema.setSchemaForSchemaQNamePrefix("xsd");
>>> schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
>>> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>>> XSDSimpleTypeDefinition s3 =
>>> XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
>>>
>>> s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
>>> "string"));
>>>
>>> XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
>>> facet.setLexicalValue("\\d{2}.\\d{1}");
>>> s3.getFacetContents().add(facet);
>>>
>>> System.out.println (s3.getFacets() + " " +
>>> s3.isValidLiteral("abcd"));
>>> schema.getContents().add(s3);
>>> schema.update(true);
>>> System.out.println (s3.getFacets() + " " +
>>> s3.isValidLiteral("abcd"));
>>> ------------------------------------------------------------ -------
>>>
>>> No matter what I try, I cannot get the added pattern facet to print
>>> or the literal validation to fail. What am I missing?
>>>
>>> Thx,
>>> -Ashish
>>
>>
Re: Facets - dynamically updating [message #599065 is a reply to message #70512] Mon, 30 October 2006 12:10 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000809010801070604080108
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ashish,

Until you put your schema in an XSD Resource (which calls
XSDSchema.setSchemaLocation with the URI of that resource), the schema
won't be fully type analyzed. So the minimum you need to do, short of
putting the schema in a proper resource, is to add the line:

schema.setSchemaLocation("main.xsd");


Ashish Deshpande wrote:

> Hi,
> I am having a problem adding/using a facet. Here's the code:
>
> ------------------------------------------------------------ -------
> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
> schema.setSchemaForSchemaQNamePrefix("xsd");
> schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>
> XSDSimpleTypeDefinition s3 =
> XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
>
> s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
> "string"));
>
> XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
> facet.setLexicalValue("\\d{2}.\\d{1}");
> s3.getFacetContents().add(facet);
>
> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
>
> schema.getContents().add(s3);
> schema.update(true);
> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
> ------------------------------------------------------------ -------
>
> No matter what I try, I cannot get the added pattern facet to print or
> the literal validation to fail. What am I missing?
>
> Thx,
> -Ashish



--------------000809010801070604080108
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ashish,<br>
<br>
Until you put your schema in an XSD Resource (which calls
XSDSchema.setSchemaLocation with the URI of that resource), the schema
won't be fully type analyzed.&nbsp; So the minimum you need to do, short of
putting the schema in a proper resource, is to add&nbsp; the line:<br>
<blockquote>schema.setSchemaLocation("main.xsd");<br>
</blockquote>
<br>
Ashish Deshpande wrote:
<blockquote cite="midei4mdr$2t4$1@utils.eclipse.org" type="cite">Hi,
<br>
I am having a problem adding/using a facet. Here's the code:
<br>
<br>
------------------------------------------------------------ -------
<br>
XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
<br>
schema.setSchemaForSchemaQNamePrefix("xsd");
<br>
schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <br>
XSDSimpleTypeDefinition s3 =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
<br>
&nbsp;&nbsp;&nbsp;&nbsp;
s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
"string"));
<br>
<br>
XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
<br>
facet.setLexicalValue("\\d{2}.\\d{1}");
<br>
s3.getFacetContents().add(facet);
<br>
<br>
System.out.println (s3.getFacets() + "&nbsp;&nbsp; " +
s3.isValidLiteral("abcd"));
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <br>
schema.getContents().add(s3);
<br>
schema.update(true);
<br>
System.out.println (s3.getFacets() + "&nbsp;&nbsp; " +
s3.isValidLiteral("abcd"));
<br>
------------------------------------------------------------ -------
<br>
<br>
No matter what I try, I cannot get the added pattern facet to print or
the literal validation to fail. What am I missing?
<br>
<br>
Thx,
<br>
-Ashish
<br>
</blockquote>
<br>
</body>
</html>

--------------000809010801070604080108--
Re: Facets - dynamically updating [message #599081 is a reply to message #70532] Mon, 30 October 2006 13:50 Go to previous message
Eclipse User
Originally posted by: ashish.deshpande.cc

Thanks Ed. I will try that.

I guess this means that there is no way to use an
XSDSimpleTypeDefinition (with a pattern facet) to assess the validity of
a literal without adding it to a schema etc.

I really just want to create a new simple type (with base "string"), add
a pattern facet, validate some literals against it and then discard this
simple type. Not that big a deal to add it to a schema etc. but I'm just
wondering.

I tried assessments but that didn't do what I wanted either.

Thx,
-Ashish


Ed Merks wrote:
> Ashish,
>
> Until you put your schema in an XSD Resource (which calls
> XSDSchema.setSchemaLocation with the URI of that resource), the schema
> won't be fully type analyzed. So the minimum you need to do, short of
> putting the schema in a proper resource, is to add the line:
>
> schema.setSchemaLocation("main.xsd");
>
>
> Ashish Deshpande wrote:
>> Hi,
>> I am having a problem adding/using a facet. Here's the code:
>>
>> ------------------------------------------------------------ -------
>> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
>> schema.setSchemaForSchemaQNamePrefix("xsd");
>> schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
>> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>>
>> XSDSimpleTypeDefinition s3 =
>> XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
>>
>> s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
>> "string"));
>>
>> XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
>> facet.setLexicalValue("\\d{2}.\\d{1}");
>> s3.getFacetContents().add(facet);
>>
>> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
>>
>> schema.getContents().add(s3);
>> schema.update(true);
>> System.out.println (s3.getFacets() + " " + s3.isValidLiteral("abcd"));
>> ------------------------------------------------------------ -------
>>
>> No matter what I try, I cannot get the added pattern facet to print or
>> the literal validation to fail. What am I missing?
>>
>> Thx,
>> -Ashish
>
Re: Facets - dynamically updating [message #599093 is a reply to message #70551] Mon, 30 October 2006 16:09 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26054
Registered: July 2009
Senior Member
Ashish,

Yes, you definitely need to build a full instance, i.e., a type within a
schema to get it to work.


Ashish Deshpande wrote:

> Thanks Ed. I will try that.
>
> I guess this means that there is no way to use an
> XSDSimpleTypeDefinition (with a pattern facet) to assess the validity
> of a literal without adding it to a schema etc.
>
> I really just want to create a new simple type (with base "string"),
> add a pattern facet, validate some literals against it and then
> discard this simple type. Not that big a deal to add it to a schema
> etc. but I'm just wondering.
>
> I tried assessments but that didn't do what I wanted either.
>
> Thx,
> -Ashish
>
>
> Ed Merks wrote:
>
>> Ashish,
>>
>> Until you put your schema in an XSD Resource (which calls
>> XSDSchema.setSchemaLocation with the URI of that resource), the
>> schema won't be fully type analyzed. So the minimum you need to do,
>> short of putting the schema in a proper resource, is to add the line:
>>
>> schema.setSchemaLocation("main.xsd");
>>
>>
>> Ashish Deshpande wrote:
>>
>>> Hi,
>>> I am having a problem adding/using a facet. Here's the code:
>>>
>>> ------------------------------------------------------------ -------
>>> XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
>>> schema.setSchemaForSchemaQNamePrefix("xsd");
>>> schema.getQNamePrefixToNamespaceMap().put(schema.getSchemaFo rSchemaQNamePrefix(),
>>> XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
>>> XSDSimpleTypeDefinition s3 =
>>> XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
>>>
>>> s3.setBaseTypeDefinition(schema.getSchemaForSchema().resolve SimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001 ,
>>> "string"));
>>>
>>> XSDPatternFacet facet = XSDFactory.eINSTANCE.createXSDPatternFacet();
>>> facet.setLexicalValue("\\d{2}.\\d{1}");
>>> s3.getFacetContents().add(facet);
>>>
>>> System.out.println (s3.getFacets() + " " +
>>> s3.isValidLiteral("abcd"));
>>> schema.getContents().add(s3);
>>> schema.update(true);
>>> System.out.println (s3.getFacets() + " " +
>>> s3.isValidLiteral("abcd"));
>>> ------------------------------------------------------------ -------
>>>
>>> No matter what I try, I cannot get the added pattern facet to print
>>> or the literal validation to fail. What am I missing?
>>>
>>> Thx,
>>> -Ashish
>>
>>
Previous Topic:Facets - dynamically updating
Next Topic:Any C Parser for XSD?
Goto Forum:
  


Current Time: Sat Sep 20 20:05:31 GMT 2014

Powered by FUDForum. Page generated in 0.04057 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software