我讨厌XML

XML现在被越来越广泛的应用了,不过我觉得它已经变了,本来它是为了简单,容易读懂而设计的,但是现在,它彻底变成了只有机器才能读懂的东西。可恶的是,我的工作中还是要经常读XML文档,有时候甚至要读XML Schema来确定一个文档的合法性 😐 。号称最好的XML SPY,也就那么回事,编辑起来一点都不方便。 一个例子就是XACML。这个东西是BEA和EnTrust,Sun等公司合伙搞出来的一个OASIS标准,用来表述授权的策略。我们公司以前的一个产品,也有一种自己发明的授权策略表述语言。如果要表示这么一个策略: 当用户user_1访问resource_1的时候,具有role_1的角色 用我们以前的表述语言,大概这么写: grant( user_1, resource_1, role_1 ) 如果用XACML来表述,就得象下面这样。实在是,让人无法恭维。呵呵,大概就是为了软件公司能赚钱吧。。。 <Policy xmlns="urn:oasis:names:tc:xacml:2.0:policy:schema:os" PolicyId="urn:bea:xacml:2.0:entitlement:role:permitRole" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"> <Target> <Resources> <Resource> <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">resource_1</AttributeValue> <ResourceAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:2.0:resource:resource-ancestor-or-self" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" /> <ResourceMatch> <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">role_1</AttributeValue> <ResourceAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:2.0:subject:role" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" /> </ResourceMatch> </Resource> </Resources> <Actions> <Action> <ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:anyURI-equal"> <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI"> urn:oasis:names:tc:xacml:2.0:actions:enableRole</AttributeValue> <ActionAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#anyURI" MustBePresent="true" /> </ActionMatch> </Action> </Actions> </Target> <Rule RuleId="primary-rule" Effect="Permit"> <Condition> <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in"> <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">user_1</AttributeValue> <SubjectAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" DataType="http://www.w3.org/2001/XMLSchema#string" SubjectCategory="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" /> </Apply> </Condition> </Rule> <Rule RuleId="deny-rule" Effect="Deny" /> </Policy>

十二月 15, 2006 · Shawn Ma